[Python-Dev] Using and binding relative names (was Re: PEP for Better Control of Nested Lexical Scopes) (original) (raw)
Steven Bethard steven.bethard at gmail.com
Thu Feb 23 04:58:57 CET 2006
- Previous message: [Python-Dev] Using and binding relative names (was Re: PEP for Better Control of Nested Lexical Scopes)
- Next message: [Python-Dev] Using and binding relative names (was Re: PEP for Better Control of Nested Lexical Scopes)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Steven Bethard wrote:
And, as you mention, it's consistent with the relative import feature.
Greg Ewing wrote:
With imports, .foo is an abbreviation for myself.foo, where myself is the absolute name for the current module, and you could replace all instances of .foo with that.
Phillip J. Eby wrote:
Actually, "import .foo" is an abbreviation for "import myparent.foo", not "import myparent.myself.foo".
If we wanted to be fully consistent with the relative import mechanism, we would require as many dots as nested scopes. So:
def incrementer(val): def inc(): .val += 1 return .val return inc
but also:
def incrementer_getter(val):
def incrementer():
def inc():
..val += 1
return ..val
return inc
return incrementer
(Yes, I know the example is silly. It's not meant as a use case, just to demonstrate the usage of dots.) I actually don't care which way it goes here, but if you want to make the semantics as close to the relative import semantics as possible, then this is the way to go.
STeVe
Grammar am for people who can't think for myself. --- Bucky Katt, Get Fuzzy
- Previous message: [Python-Dev] Using and binding relative names (was Re: PEP for Better Control of Nested Lexical Scopes)
- Next message: [Python-Dev] Using and binding relative names (was Re: PEP for Better Control of Nested Lexical Scopes)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]