Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] Using and binding relative names (was Re: PEP forBetter Control of Nested Lexical Scopes)

Steven Bethardsteven.bethard at gmail.com
Thu Feb 23 04:58:57 CET 2006


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 importmechanism, we would require as many dots as nested scopes.  So:   def incrementer(val):       def inc():           .val += 1           return .val       return incbut 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, justto demonstrate the usage of dots.)  I actually don't care which way itgoes here, but if you want to make the semantics as close to therelative 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


More information about the Python-Devmailing list

[8]ページ先頭

©2009-2025 Movatter.jp