[Tutor] Reviewing scripts & main statements in function

Barnaby Scott barnabydscott at yahoo.com
Thu Jan 15 17:20:21 EST 2004


Thanks very much for that. I was interested to see
your comments, and am as pleased to receive stylistic
help as much as any other kind.

Can I ask one other question, which may have wider
relevance for others?:

You (or another contributor) put the main statement
block into a function and then called it with the line

if __name__ == '__main__': main()

I have seen this before - is it universally good
practice? What about scripts that were only ever
intended to be run standalone?

It also makes me think - if this is good practice,
should you always be prepared for someone to import
your script as a module, and maybe even subclass some
of my objects etc? If they did, they would get a rude
shock, as the classes are not very 'self-contained'.
For example they make reference to each other and to
global variables in the module. Should classes always
have every piece of data they will need passed to them
at the creation of an instance, or in other ways make
themselves 'available' more universally?

Thanks again - I really do appreciate all these
opportunites to learn more.



>I put up your program and made some
> changes
> to it at
> http://zope.org/Members/LittleDan/PissiPissi
> . Most of the error were really minor or just
> stylistic (but there are coding conventions that
> should be followed), although I may be missing
> something. Could other people review the code?
> 
> Daniel Ehrenberg
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Hotjobs: Enter the "Signing Bonus"
> Sweepstakes
> http://hotjobs.sweepstakes.yahoo.com/signingbonus
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor


__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus



More information about the Tutor mailing list