Implementation of the global statement

Bengt Richter bokr at oz.net
Fri Nov 29 14:33:11 EST 2002


On Thu, 28 Nov 2002 20:20:57 -0500, "Terry Reedy" <tjreedy at udel.edu> wrote:

>
>"Bengt Richter" <bokr at oz.net> wrote in message
>news:as5ugi$a48$0 at 216.39.172.122...
>>  >>> def foo(x): print x
>>  ...
>>  >>> bar = foo.__get__('Hi via foo')
>>  >>> bar()
>>  Hi via foo
>
>This is a new one for me:
>
>>>> def f(): pass
>...
>>>> f.__get__
><method-wrapper object at 0x015197B0>
>>>> f.__get__.__doc__
>'descr.__get__(obj[, type]) -> value'
>
>Seems to be a new, undocumented (?, not in indexes) method producing a
>new, undocumented (?) internal type.  Not something to bank a product
>on ;-)
>
I was reading

    http://www.python.org/2.2/descrintro.html

and PEP 252

    http://www.python.org/peps/pep-0252.html

and trying stuff ;^P when I noticed that dir(foo) showed __get__, so one thing let to another ;-)

but while that stuff is really interesting, what I was reflecting on was
whether internals docs ought *all* to have some kind of predictable footnoting
saying what's off limits for ordinary use.

Or should one assume that it's all obviously off limits? It may not be so obvious
to newbies sometimes -- and remember, we're all newbies, just on different subjects ;-)
(to paraphrase Will Rogers).

Regards,
Bengt Richter



More information about the Python-list mailing list