Marcus answered most of the issues. On 01/23/2015 07:24 PM, Greg Freemyer wrote:
Should I have the equivalent of main()? Not necessary. Python begins execution from the start of the file.
Should I have an exit at the bottom of the file? Not necessary.
Note that you do not need a return at the end of functions unless you
want to return a value.
I usually set up my stuff as object oriented. Things like:
#!/usr.bin/python
"""
Some documentation
"""
class MyClass:
def __init__(self):
... init stuff
# more methods
def aMethod(self):
---code--
if __name__ == "__main__":
# instantiate MyClass - this will cause __init__() to run.
# the above if statement is true when the program is executed by
hand. But if you include it as a module
# this will not be executed. Note that the variable, 'myClass', can
be used to access class variables or run class methods.
# normally I use the __init__() function to start everything.
myClass = MyClass()
--
Jerry Feldman