Why we will use obj$func() often

Mike C. Fletcher mcfletch at rogers.com
Mon Apr 26 01:03:58 EDT 2004


Mark Hahn wrote:

>"Greg Ewing" <greg at cosc.canterbury.ac.nz> wrote in message
>news:c6hvdk$bs63j$1 at ID-169208.news.uni-berlin.de...
>  
>
>>Mark Hahn wrote:
>>    
>>
...

>You cannot.  Yes it literally means the immediately surrounding function.
>In your example, I can't think of any scheme we've discussed that accesses x
>in function f.  Python surely cannot.
>  
>
Well, not yet, it was explicitly not implemented until something elegant 
came along IIRC.

>I understand this is quite limiting, but it's simple. As always, I'm open to
>suggestions...
>  
>
How about:

    .this (surrounding scope, often an object)
    ..this (surrounding scope + 1, such as a module or a nested-class' 
parent

Seems elegant in a certain way.  The construct is reminiscent of 
directory specifiers, and meshes nicely with the attribute access 
syntax.  Gets a little unwieldy if you're having hugely nested 
constructs, but then that's already unwieldy, so more pain too them :) .

Have fun,
Mike

_______________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://members.rogers.com/mcfletch/






More information about the Python-list mailing list