def
Mikael Olofsson
mikael at isy.liu.se
Wed Aug 23 03:08:10 EDT 2000
On 22-Aug-00 Matthew Schroeder wrote:
> Is there some way to define the funtions at the end of the module (.py
> file)?
>
> I'm used to having the functions defined at the end of the file, then at
> the
> top of the file is where the functions are actually called.
Matthew,
you can always do the following:
def main():
Do all your stuff here, call functions et cetera.
def spam1(...)
whatever
def spam2(...)
whatever
main()
And as people often recommend: Change the last line to
if __name__=='__main__':
main()
which will invoke main() automagically only if you invoke your script
is executed directly, but ignores it if your script is imported.
/Mikael
-----------------------------------------------------------------------
E-Mail: Mikael Olofsson <mikael at isy.liu.se>
WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael
Phone: +46 - (0)13 - 28 1343
Telefax: +46 - (0)13 - 28 1339
Date: 23-Aug-00
Time: 09:01:03
/"\
\ / ASCII Ribbon Campaign
X Against HTML Mail
/ \
This message was sent by XF-Mail.
-----------------------------------------------------------------------
More information about the Python-list
mailing list