Reputation: 19
I haven't found precise answer to the question (Python).
Is a good practice to intialize variables at the beggining or should that be done later? And what type of the value should I give them at the beginning?
example:
variable_str = None # Should I give None to them all?
variable_int = None #
variable_float = 0.0 # Should I give float for type float?
# Code.......
# I will use that variables later on,....
Some say it is a good practice, but I am confused which data type should be used? Python is dynamically typed, but nevertheless what is the best practice?
Upvotes: 1
Views: 206
Reputation: 375634
There's no need to mention variables before you first need to give them an actual useful value. Don't put dummy values at the top of your program.
Upvotes: 1