Posts by escapistabr • 847 points
32 posts
-
2
votes1
answer27
viewsA: Doubt eclipse tool
By right-clicking the class you can define the getters/setters methods: And once on the screen shown, you can select attributes as well as only generate getter or Setter:…
-
1
votes2
answers136
viewsA: What does test_size = 20 mean?
As defined, the value 20 and the value 0 represent standard values, that is, if the function train_test_split is called without values for attributes test_size, random_state then these values will…
pythonanswered escapistabr 847 -
1
votes1
answer53
viewsA: Do not re-enter an existing login user
You could check if the user, based on the login, already exists before performing the insertion. public boolean usuarioExistente(Usuario usuario) { try { Usuario usuario = (Usuario)…
-
1
votes3
answers353
viewsA: How to create a accumulator
There are a few different ways of doing this, but as I think you’re getting started, the idea would be to visualize each step of structure used to understand. An initial way would be to have a list,…
pythonanswered escapistabr 847 -
0
votes1
answer226
viewsA: Example of Python service from Post method
It’s actually something very similar to your example. You need to change the method to POST and if you expect content like application/json, the request object may be used to retrieve the…
-
4
votes2
answers2161
viewsA: How to delete a foreign key from Mysql
You could first remove Foreign key with the following syntax: ALTER TABLE pessoa DROP FOREIGN KEY NOME_FOREIGN_KEY; If you need to remove indexes: ALTER TABLE pessoa DROP INDEX NOME_INDEX; Then you…
mysqlanswered escapistabr 847 -
1
votes1
answer1502
viewsA: How to print an element from a list of lists in python
You can do it this way: l = [('nome1', 1), ('nome2', 2)] # Cria lista de tuplas for t in l: print(t[0]) # Imprime o primeiro elemento da tupla
-
0
votes1
answer41
viewsA: I want my def to print(): ... receive my def mais_alto(): and my def mais_baixo(): and print the results
You can call the respective methods directly. It was also necessary to make some small changes to your code, see if it helps: lista_aluno = [] lista_tamanho =[] def nome_altura(): for i in…
python-3.xanswered escapistabr 847 -
0
votes1
answer189
viewsA: Select advanced sql
Add the clause GROUP BY would be as follows: UPDATE posts SET id_post_gru = ( SELECT COUNT(id_grupo) FROM posts WHERE id_grupo = 70 GROUP BY id_group );…
mysqlanswered escapistabr 847 -
5
votes2
answers77
viewsA: Updating multiple records at the same time
Make sure it helps you this way: UPDATE usuarios SET email = CASE id WHEN 1 THEN '[email protected]' WHEN 2 THEN '[email protected]' WHEN 3 THEN '[email protected]' ELSE id END ; If necessary, you can remove…
-
0
votes3
answers462
viewsA: How to limit a user to only access their own data?
You wouldn’t necessarily need to use some security feature for that. In a simpler way, imagining that you have an authentication process in your application, after authenticating and identifying the…
-
4
votes3
answers2049
viewsA: How to start full screen window with Tkinter?
Try to do so: windows.attributes('-fullscreen',True) PS: I used this solution to solve this problem; when I searched, I searched in English and found the following thread Python 3.3 Tkinter…
-
1
votes2
answers2574
viewsA: Is there a command to finish the program in Python?
In this example of yours, it would help if you put a clause Else? Something like that: p=input('Você deseja somar?') if p=='sim': print(soma()) # Realiza somente a soma caso a condição seja…
-
0
votes2
answers238
viewsA: print a returned Servlet list in a jsp
You need to recover the properties of your object System individually for each column. In your example it would be something like: <c:forEach var="obj" items="${lista}"> <tr>…
-
2
votes1
answer70
viewsA: How to protect myself against "Mongoinjection"
I found the following descriptive in the Soen thread and found it interesting to share in this your question: The point is convert and interpret input data Mongodb avoids potential problems of this…
-
1
votes1
answer615
viewsA: How to recover the return of a function that was executed within a Thread in Python3?
You could use multiprocessing.pool import ThreadPool instead of from threading import Thread in its implementation? It would be as follows: from multiprocessing.pool import ThreadPool import time…
-
1
votes2
answers91
viewsA: Help with String algorithm
For the part of counting the total times of a given String in the term you can use regular expression. For example: String termo = "banana"; Pattern padrao = Pattern.compile("na"); Matcher…
-
5
votes1
answer312
viewsA: Java waiting for the end of a . bat
I went through something similar and I solved it in the following way: Process procBat = Runtime.getRuntime().exec([comando]); int retorno = procBat.waitFor(); // Se o retorno for 0 então o processo…
javaanswered escapistabr 847 -
0
votes1
answer239
viewsA: javax.ws.rs.client.Client set timeout
I found that it is not really possible to define values for timeout when this type of object is injected. As an alternative solution I changed the http client to Apache org.apache.httpcomponents and…
-
0
votes1
answer239
viewsQ: javax.ws.rs.client.Client set timeout
I have a web application where at a certain time I make requests on a endpoint using JAX-RS RestEasy as follows: // Outros códigos acima @Inject private Client client; ... WebTarget webTarget =…
-
0
votes2
answers198
viewsA: How do select in specific columns and continue to receive an entity list and not an Object array?
An entity list will not be possible in your model, but what you can do is create a class with the attributes you need and provide a constructor with those attributes. Behold: public class…
-
1
votes2
answers704
viewsA: Problems with the result of a sum between double-type numbers
For accounts with large number of decimals it may be interesting to use the class java.math.BigDecimal So the account would be this way: BigDecimal valor1 = new BigDecimal("615.6555"); BigDecimal…
-
1
votes1
answer122
viewsA: How can I replace an error with a print without terminating the program? Python 3
You can treat the error with a Try/except block, something like that: def entrar_dados(): try: numero = int(input('Entre com um numero: ')) except ValueError as e: print('Voce nao digitou um numero…
python-3.xanswered escapistabr 847 -
0
votes2
answers186
viewsA: Display items from a list in the Django html
Tries to add a line break: {{item}} <br/>
-
6
votes3
answers2770
viewsA: Select from the line with the highest ID
One option, not to use sub queries, could be to sort down by ID and return only the record most recent select * from val_produtos order by id desc limit 1…
-
1
votes1
answer2338
viewsA: Python executable problem generated by pyinstaller
I had a very similar problem and managed to solve with the command: pyinstaller --noconsole exec_main.py Make sure it helps. Reference: Windows and Mac OS X specific options…
-
1
votes1
answer46
viewsA: Using the Save from Spring data command
You don’t necessarily need to write down all your attributes with @Column. If you choose not to annotate the application will adopt the default attribute name as the name of the column in the…
answered escapistabr 847 -
3
votes1
answer81
viewsA: Python Dictionary 3
The get(key, default) function returns the value in the map according to the key key specific. On the map we have the following keys: 1, 2, 3, 4, and their values are as follows:: 1, 1, 2, 3 In the…
pythonanswered escapistabr 847 -
1
votes1
answer3010
viewsA: Django error Art matching query does not exist.
It is possible that the record you are trying to recover by id (id_arte) does not exist in the database. By the way then, you would like to check first if the record exists before you enter. If this…
djangoanswered escapistabr 847 -
3
votes1
answer815
viewsA: Input read more than one string line
You could create a function to perform the reading of multiple lines whereas the processing will be stopped when there is more than a certain number N line breaking. Example (for N > 1): def…
-
0
votes2
answers64
viewsA: Code continues running after game’s end
This is happening because despite the code entering the specific condition, the processing continues from line 15. You need to stop running the game with the following command: import sys sys.exit()…
pythonanswered escapistabr 847 -
3
votes1
answer70
viewsA: How to store questions and answers in the bank
You could use some specific markup to indicate the use of the "__" set and write to the base with that markup. When the recover application you could replace it with the true characters again.…