[Python-ideas] PEP for executing a module in a package containing relative imports
steven.bethard at gmail.com
Mon Apr 23 03:24:43 CEST 2007
On 4/22/07, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Steven Bethard wrote:
> > if there's nothing to be passed to the function, why make it a
> > function at all?
> I don't usually like to put big lumps of init code
> at the module level, because it pollutes the module
> namespace with local variables. So I typically end
> up with
> def main():
> if __name__ == "__main__":
> So I'd be quite happy if I could just define a
> function called __main__() and be done with. I
> don't understand why there's so much opposition
> to that idea.
I guess I'm just the odd one out here in that I parse my arguments
before passing them to module-level functions. So my code normally
if __name__ == '__main__':
... a few lines of argument parsing code ...
some_function_name(args.foo, args.bar, args.baz)
That is, I do the argument parsing at the module level, and then call
the module functions with more meaningful arguments than sys.argv.
I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
--- Bucky Katt, Get Fuzzy
More information about the Python-ideas