You are not logged in.

#1 2006-07-18 23:04:14

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,622
Website

python 2.5 talk.

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

#2 2006-07-18 23:19:22

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,622
Website

Re: python 2.5 talk.

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

#3 2006-07-18 23:59:51

T-Dawg
Forum Fellow
From: Charlotte, NC
Registered: 2005-01-29
Posts: 2,736

Re: python 2.5 talk.

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

Board footer

Powered by FluxBB