You are not logged in.
Pages: 1
Interesting change in python 2.5
http://docs.python.org/dev/whatsnew/pep-328.html
Is it just me remembering incorrectly, or was the 'from import' syntax frowned upon, because of possible namespace collisions.
With this new pep, it seems like the 'from import' syntax is now the recommended method, with the 'import' being relegated to 'not working with relative imports'.
I see the reasoning for full path imports, but I guess I don't understand fully the change.
Are they saying that the python std lib will always be loaded first, in the event of an import, unless the 'from import' syntax is used..or are they saying that import will only load from the std lib.
Maybe some of you chaps can shine some enlightenment on it for me...
"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍
Offline
hmm...the full pep explains it a bit better.
http://www.python.org/dev/peps/pep-0328/
I am still now sure how the 'import' statement works. I believe I understand how the 'from import' type works now.
'import' is absolute, but absolute based on what?
The full system path?
The path of instantiation?
Or is import only going to work for the std library now, and all other module loading is to be done with the 'from import' syntax..
:?
"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍
Offline
Yeah a bit confusing. The way I understand it is in 2.5 and 2.6 from __future__ import absolute_import will be recommended but not enforced. In 2.7 that will be done automatically so import string will always be known as the absolute module. And loading packages modules will require the '.' method: from .pkg import string or whatever syntax they decide on -I think this part is just to further clarify.
Absolute refering to those along sys.path:
[...].. it is proposed that all import statements be absolute by default (searching sys.path only) with special syntax (leading dots) for accessing package-relative imports.
Offline
Pages: 1