Names and bindings, round 42 (was Re: questions about scope/threading)

Aahz aahz at pythoncraft.com
Sun Dec 8 16:08:00 EST 2002


In article <asqb48$77b$1 at wheel2.two14.net>,  <maney at pobox.com> wrote:
>Aahz <aahz at pythoncraft.com> wrote:
>>
>> Generally speaking, in Python a "binding" *is* a reference.  Of course
>> "bound" gets confusing because it also refers to instance methods.  What
>> subset of references were you thinking "bound" was?
>
>I guess I was thinking of binding to a name, as opposed to anonymous   
>references.  And yeah, I have noticed the word gets used in a mess of  
>different ways.  :-)

Python code never uses reference/dereference semantics explicitly, so it
only makes sense (at best) to refer to named bindings and anonymous
bindings.  Even then, it's a tenuous distinction.  Consider:

class C:
    pass

C.x = 'spam'
print C.__dict__['x']

Is "x" a name or an anonymous binding?  About the only time it makes
sense to refer to anonymous bindings is when the binding truly is
hidden:

def f(x=None):
    pass

Where is the binding for the default value of "x" stored?  ;-)
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"To me vi is Zen.  To use vi is to practice zen.  Every command is a
koan.  Profound to the user, unintelligible to the uninitiated.  You
discover truth everytime you use it."  --reddy at lion.austin.ibm.com



More information about the Python-list mailing list