[Python-ideas] start, test, init
Daniel Watkins
daniel at daniel-watkins.co.uk
Mon Dec 2 13:39:48 CET 2013
On Mon, Dec 02, 2013 at 01:35:31PM +0100, spir wrote:
> * Why has the idiom "(el)if __name__ == '__main__':" has to be that
> obscure? and involve unnecessary knwoledge of Python arcanes (for a
> newcomer)
It seems to me that having to know the string "if __name__ ==
'__main__'" is about the same level of arcana as knowing the name of a
magic function that does the same.
> * Having a std (albeit not required) high-level software structure
> is a net gain for the community of Python programmers (instead of
> everyone doing their own way... when they do).
"if __name__ == '__main__'" is, by necessity, standard across all Python
programs. And if I want to run the tests for a project, I would expect
'./setup.py test' to run them for me.
If a project has more than one entry point, how would I know which one
to run to get the tests to work? Or would they all have to implement
the test function identically?
Dan
More information about the Python-ideas
mailing list