Login Register






Tutorial The do's and don'ts of programming filter_list
Author
Message
RE: The do's and don'ts of programming #11
(08-28-2016, 04:03 AM)God Wrote:
(08-28-2016, 03:05 AM)phyrrus9 Wrote:
(08-27-2016, 06:12 PM)God Wrote: Could you give a python example with this. I haven't used python in a while and I just want to make sure I'm understanding what you mean. Thanks.

Code:
#!/usr/bin/python

integer_variable = 5
integer_variable2 = 3
integer_result = 0     #assigned during addition routine

######################
#addition routine
######################
integer_result = integer_variable + integer_variable2

vs defining variables on the fly
Code:
#!/usr/bin/python

integer_variable = 5
integer_variable2 = 3

######################
#addition routine
######################
integer_result = integer_variable + integer_variable2     #integer_result isn't defined until the addition routine, considered bad practice by many, and will leave you open to debugging issues

Thank you for clarifying. I'm pretty sure I'm guilty of this as I started with Python and I for one thought not needing to initialize variables was part of the convenience of the language.

It is a "convenience", and such a thing is why Python is considered a "quick and dirty" language. The quick part is because it has a lot of interfaces that you can work with and is mostly code generation, and the dirty is because it allows you to keep bad habits and still use it.

[+] 1 user Likes phyrrus9's post
Reply







Users browsing this thread: 1 Guest(s)