[Python-ideas] start, test, init

Mark Janssen dreamingforward at gmail.com
Mon Dec 2 02:19:36 CET 2013


> There should be 3 top-level functions predefined by the language:
> * 'start' : start func for a module run as an app (or 'main')
> * 'test'  : main func of a module's test suite
> * 'init'  : module init code, rather when imported

1)  I'd make "main" a keyword, used to denote the program start point,
and let the interpreter bail-out if it encounters more than one "main"
section.  Yes that keyword would only be used for that one, simple
purpose, but it *is* a special purpose.  This would also solve the
circular import issues, because now you have a well-defined *root* in
which to construct a graph and check for cycles.
2)  I think testing should also be more "built-into" the interpreter
environment.  I like the idea of a python "-t" flag or something which
makes it runs doctests.  In which case, I'd also what a test()
built-in, so that I can use it *within* the interpreter environment
also, making sure invariants are preserved when modifying and re-using
code.
3) with a "main" keyword, this wouldn't be absolutely necessary.
You'll know where your top-level scope is.

-- 
MarkJ
Tacoma, Washington


More information about the Python-ideas mailing list