1
The database driver I am using returns the data of a record in the form of an example tuple ('João', 32, False)
.
I’m thinking of a pythonic way of passing this data to the constructor of a Person class, to create an object with the data contained in the tuple.
I had seen somewhere something about it being possible to pass a tuple as a function parameter and it would recognize the values contained in the tuple as being the value of each parameter that the function expects.
I’m not sure, but I think I saw something along those lines when I started my studies in python.
The answer is correct, but I don’t know if I’d call it pythonic. After all, "Explicit is better than implicit", and nothing more explicit in a passage of parameters than simply passing the parameters.
– Pablo Almeida
Buddy, wouldn’t it be better if you put the function so it only took one line? So it would be more efficient for your code and avoid using many . format()
– Vinicius Mesel
@Viniciusmesel: Yes, it is another possibility, too. But the above example is only didactic and not aimed at performance :)
– Gomiero
@Gomiero understand friend! I will add this answer also to be able to help you better.
– Vinicius Mesel