Finding the instance reference of an object [long and probably boring]
castironpi at gmail.com
Sat Nov 8 02:21:14 CET 2008
On Nov 7, 3:39 pm, Arnaud Delobelle <arno... at googlemail.com> wrote:
> Aaron Brady <castiro... at gmail.com> writes:
> > Furthermore, some class models variables like this:
> > a.b= 'abc'
> > a.c= 'def'
> > a.d= 'ghi'
> > It also allows index access: a, a, a, respectively. 'abc'
> > has two names: 'a.b', and 'a'. Correct?
> You know very well that a.b and a aren't names, they are function
> calls written in short hand ;)
> a.b is getattr(a, 'b')
> a is getattr(a, '__getitem__')(0)
> So they just return an object, which happens to be the same :)
Therefore objects don't need names to exist. Having a name is
sufficient but not necessary to exist. Being in a container is
neither necessary -nor- sufficient.
a is the name of an object. The object is associated with a
dictionary you can usually access. 'b' is a key in the dictionary.
More information about the Python-list