other python ideas
Jeff Petkau
jpet at eskimo.com
Mon Apr 9 00:32:34 EDT 2001
More information about the Python-list mailing list
Mon Apr 9 00:32:34 EDT 2001
- Previous message (by thread): other python ideas
- Next message (by thread): other python ideas
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Douglas Alan <nessus at mit.edu> wrote in message news:lcvgoeiva4.fsf at gaffa.mit.edu... > > mymodule::foo(a, b, c) > > This syntax would invoke mymodule.foo(), and would load module > "mymodule" it if it wasn't already loaded. You'd probably also want > some sort of module aliasing notation so you could use > > alias m my_really_long_named_module > m::foo(a, b, c) > > in place of > > my_really_long_named_module::foo(a, b, c) How is this any better than: import my_really_long_named_module as m m.foo(a, b, c) ? For avoiding import statements, you could write something like this: class ModuleGetter: def __getattr__(self,name): if name.startswith('__'): raise AttributeError return __import__(name) module = ModuleGetter() And now you can do without the imports: module.mymodule.foo(a, b, c) module.os.chmod(blah, blah) x = module.re.compile('[a-z]') --Jeff Petkau
- Previous message (by thread): other python ideas
- Next message (by thread): other python ideas
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list