Posts by hdiogenes • 192 points
4 posts
-
1
votes2
answers399
viewsA: Can you replace commands with variables in python?
Apparently what you’re trying to do is create a macro, resource that Python does not have. You can try using macropy, a library that implements this, but apparently in a very complicated way…
python-3.xanswered hdiogenes 192 -
2
votes1
answer170
viewsA: Receiving Nan (not a number) when reading a file. CSV with numpy
As already indicated in the comments, it is only the delimiter parameter that is wrong. When changing ";" for "," the code works: import numpy as np valores = np.genfromtxt("arquivo.csv",…
-
2
votes3
answers288
viewsA: Search for tuple in an array
If, instead of a list of lists, you can upload b as a dictionary (or transform b in a dictionary bd, as I did in the example below) the code can become more intuitive, just one bd.get to locate the…
-
2
votes5
answers11991
viewsA: How to validate and calculate the control digit of a CPF
Here is an example that can be used both on the command line and as a Python library, with doctests. import re def validar_cpf(cpf): """ Retorna o CPF válido sanitizado ou False. # CPFs corretos…