scope of function parameters
Ben Finney
ben+python at benfinney.id.au
Sun May 29 17:42:19 EDT 2011
Peter Pearson <ppearson at nowhere.invalid> writes:
> Python works in terms of objects having names, and one
> object can have many names.
Or no names. So it's less accurate (though better than talking of
“variables”) to speak of Python objects “having names”.
> The names b and c aren't boxes that hold things, they are -- in the
> words of one of this group's old hands -- sticky-note labels that have
> been slapped on the same object.
Right. And in that analogy, the object *still* doesn't “have a name”
(since that implies the false conclusion that the object knows its own
name); rather, the name is bound to the object, and the object is
oblivious of this.
I prefer to talk not of sticky notes, but paper tags with string; the
string leading from tag to object is an important part, and the paper
tag might not even have a name written on it, allowing the same analogy
to work for other non-name references like list indices etc.
--
\ “Pinky, are you pondering what I'm pondering?” “I think so, |
`\ Brain, but where are we going to find a duck and a hose at this |
_o__) hour?” —_Pinky and The Brain_ |
Ben Finney
More information about the Python-list
mailing list