Sure, here you go: Taken from: http://excess.org/article/2011/12/unfortunate-python/<http://excess.org/article/2011/12/unfortunate-python/?utm_source=Python+Weekly+Newsletter&utm_campaign=852b8f48be-Python_Weekly_Issue_14_December_22_2011&utm_medium=email>
------------ if __name__ == '__main__': This little wart has long been a staple of many python introductions. It lets you treat a python script as a module, or a module as a python script. Clever, sure, but it's better to keep your scripts and modules separate in the first place. If you treat a module like a script, then something imports the module you're in trouble: now you have two copies of everything in that module. I have used this trick to make running tests easier, but setuptools already provides a better hook for running tests. For scripts setuptools has an answer too, just give it a name and a function to call, and you're done. My last criticism is that a single line of python should never be 10 alphanumeric characters and 13 punctuation characters. All those underscores are there as a warning that some special non-obvious language-related thing is going on, and it's not even necessary. See also setuptools/distribute automatic script creation and also PEP 366 pointed out by agentultra on HN ------- On Thu, Dec 22, 2011 at 6:58 PM, Nikolas Stevenson-Molnar < nik.mol...@consbio.org> wrote: > Could you provide a link to the bit about __name__ == __main__? I'd be > interested in learning more about that... > > Thanks, > _Nik > > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.