Static Modules...

Robert Brewer fumanchu at amor.org
Sat Apr 17 14:03:09 EDT 2004


Grzegorz Dostatni wrote:
> If we don't need to declare variables as having a certain 
> type, why do we need to import modules into the program?
> Isn't the "import sys" redundant if all I want is to call
> "sys.setrecursionlimit(5000)"?

I'm not denying your proposal, just adding to it:

The code you posted is a handy technique for sys and other "top-level"
builtins. We still need "import as" for packages, to shorten deep
references.

import custom.framework.app.tools.listtools as lt
bag1 = lt.Bag([1,2,3])
bag2 = lt.Bag([4,5,6])
bag3 = lt.Bag([7,8,9])

--- versus ---

bag1 = custom.framework.app.tools.listtools.Bag([1,2,3])
bag2 = custom.framework.app.tools.listtools.Bag([4,5,6])
bag3 = custom.framework.app.tools.listtools.Bag([7,8,9])

...likewise, "from package import module" needs to stick around (for
similar reasons).


FuManChu




More information about the Python-list mailing list