December 2000
Intermediate to advanced
816 pages
16h 57m
English
Another fairly common request from Python programmers is the ability to import modules and module attributes into your program using names other than their original given names. One common workaround is to assign the module name to a variable:
>>> import longmodulename >>> short = longmodulename >>> del longmodulename
In the example above, rather than using longmodulename.attribute, you would use the short.attribute to access the same object. (A similar analogy can be made with importing module attributes using from-import… see below.) However, to do this over and over again, and in multiple modules can be annoying and seem wasteful. The new extended import statement will now support the following:
>>> import longmodulename ...Read now
Unlock full access