[Python-ideas] start, test, init
spir
denis.spir at gmail.com
Mon Dec 2 13:48:47 CET 2013
On 12/02/2013 02:19 AM, Mark Janssen wrote:
>> 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.
I guess that is close to my point of view, if I undertand yours correctly: there
could be an minimal amount of high-level software structure, at least about
different running modes (exec, test, import), built into the language.
Denis
More information about the Python-ideas
mailing list