word1.word2 notation

Evan Simpson evan at tokenexchange.com
Tue Aug 24 16:46:22 CEST 1999


In python, 'bar' is called an "attribute" of 'foo' (in the general case).
Note that in python, it *is* possible, and perfectly normal, to write
"foo.bar = 42".  This will create attribute 'bar' if it doesn't already
exist, and will hide any inherited binding of 'bar' if 'foo' is a subclass
or an instance.

Yeoh Yiu <squid at panix.com> wrote in message
news:oxgbtbxejea.fsf at panix7.panix.com...
> I've noticed in various languages, there is a construction
> of expressions with a dot in the middle.  It is a construction
> because the name with a dot in the middle is never explicitly
> declared, as in
>
> int foo.bar = 42;   // doesn't happen this way
>
> but rather foo is declared in one place and method (or some other
> type of entity)  bar was declared somewhere else and foo.bar was
> always available implicitly as a latent method (or as something).
>
> What is the name of this technique and the name of methods
> (or variables ?) so constructed ?







More information about the Python-list mailing list