Posts by Bruno Camargo • 519 points
20 posts
-
5
votes1
answer221
viewsQ: When is the standard model request/Answer required in the context of a REST application?
If possible, let’s imagine a context where Spring Boot and JPA are used. During the construction of some REST API, I always wonder if I should perform the standard model request/Response. For…
-
1
votes1
answer514
viewsQ: How to use Spring Data Binding Object for Snake case attributes while maintaining the Java Naming Conventions standard?
Hello, is there any way to perform Binding date of objects in Spring using Snake case? For example, suppose the following request GET on a job REST: http://localhost:8080/Foobar? foo_bar=example For…
-
3
votes1
answer434
viewsQ: How are modifiers implemented in Typescript?
Typescript supports all functionality present in Javascript (proper Ecmascript 6), and has modifiers such as: private, protected and abstract. However, in ES6 there are no such modifiers. To…
-
3
votes2
answers3545
viewsA: How to print the percentage sign in Python 2/3?
It is not recommended by the community to use the operator % for the concatenation of strings for printing, since this operator is also used to perform the resto da divisão. This way, always use the…
-
0
votes0
answers179
viewsQ: Get information from another program using Python
Hello, I would like to know how it is possible to get information from another program using Python. In question, I want to develop a blinds counter for Pokerstars. Note: blinds in poker is the set…
-
0
votes2
answers204
viewsA: Printar 2 interlaced strings
A simple solution: def entrelacar(string1=None, string2=None): s = list(string1) s2 = list(string2) resp = '' while s or s2: if s: resp += s.pop(0) if s2: resp += s2.pop(0) return resp if __name__…
-
0
votes2
answers781
viewsA: How to join 2 lists in a single Matrix?
I think this code can help you: def intercalacao(vetor_1=None, vetor_2=None): num_linhas = 3 num_colunas = 4 # cria matriz 3x4 matriz = [[0 for i in range(num_colunas)] for j in range(num_linhas)] #…
pythonanswered Bruno Camargo 519 -
0
votes1
answer1183
viewsA: How to Separate Data in Dictionary from a . txt (Python)
def monta_dicionario(caminho=None): with open(caminho, "r") as anexo: dic = {} for linha in anexo.readlines()[1:]: nomes = linha.split(" ") for nome_tel in nomes: val =…
-
0
votes1
answer2149
viewsA: List files from a folder using.listdir
It helps you? from os import listdir def listar_arquivos(caminho=None): lista_arqs = [arq for arq in listdir(caminho)] return lista_arqs if __name__ == '__main__': arquivos =…
pythonanswered Bruno Camargo 519 -
0
votes1
answer188
viewsA: PREDICT error in Scikit-Earn
As described by the comments, just use a two-dimensional array: from sklearn.naive_bayes import MultinomialNB pig1 = [1, 1, 0] pig2 = [1, 1, 0] pig3 = [1, 1, 0] dog1 = [1, 1, 1] dog2 = [0, 1, 1]…
-
1
votes3
answers942
viewsA: Number greater than 7 in a Python list
Just one more option: def maiorq(num=None, lista=None): return sum( n > num for n in lista) if __name__ == '__main__': valor = maiorq(num=7, lista=[10,8,2,4,60,3]) print(valor)…
-
12
votes3
answers5645
viewsQ: What is the purpose of declaring a function within a function?
In Python it is possible to declare a function within another function, as shown in the following code. def foo(palavra=None): print(palavra) def bar(outra_palavra=None): print(outra_palavra) if…
-
3
votes1
answer358
viewsQ: Sort lists with multiple parameters using lambda expression
Given the class Ponto, the function ordenar sort the list elements by the following criteria: first value in x, afterward y and finally value in z. Okay, the code works. But I’d like to understand…
-
2
votes2
answers423
viewsA: Identify string between two known snippets in a string
I think this might help you. comeco = "CGC" fim = "AAA" string = "CGC UUC GCU UUG GAA AAU UUG UGU GUU UUU UGU GGC UGC UCG CUG CUC AAA UUG UUC GCU GCU UUU UGU GUC CUG GCU GCU UUU AUU AUU UUA CGC UGC…
-
5
votes1
answer114
viewsQ: Is it good practice to perform Imports within methods?
Is there any advantage to doing import within methods instead of performing the "traditional" import in the program header? If I import within the method, will the module only be imported when the…
pythonasked Bruno Camargo 519 -
1
votes1
answer168
viewsA: Function removes chained list
This question has already been answered in the English OS. Python uses garbage collector for memory control. Thus, gc once wipes memory by releasing objects that are not referenced. Therefore, using…
-
1
votes2
answers104
viewsA: using any in python
lista1 = [ {'numero':'0169924233316', 'data':'2017-16-10'}, {'numero':'01687665544', 'data':'2017-16-10'}, {'numero':'01978553322', 'data':'2017-16-10'}] lista2 =…
-
0
votes1
answer245
viewsA: How to adjust focus using Opencv and Python?
I think the real-time focus adjustment takes place only on the capture device used to generate the images and not exactly with the use of Opencv. If the device has no function related to the focus…
-
3
votes1
answer489
viewsA: Prediction with Tensorflow Neural Networks
All data entry in Tensorflow is performed with placeholder. Just add another placeholder field import tensorflow as tf W1 = tf.Variable([.3], dtype = tf.float32) b = tf.Variable([-.3], dtype =…
-
1
votes3
answers3880
viewsA: HTTP status 500 Internal server error
Dude, there’s some weird stuff in your code. Come on: In the method getTodos() class Controller, you are calling the object Service with the same class name. This is not only wrong, it can cause…