Object's nesting scope

zaur szport at gmail.com
Wed Aug 26 18:49:48 CEST 2009


On 26 авг, 17:13, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
> Whom am we to judge? Sure if you propose this, you have some usecases in
> mind - how about you present these

Ok. Here is a use case: object initialization.

For example,

person = Person():
  name = "john"
  age = 30
  address = Address():
     street = "Green Street"
     no = 12

vs.

person = Person()
person.name = "john"
person.age = 30
address = person.address = Address()
address.street = "Green Street"
address.no = 12

In this example any assignment is an equivalence of setting
attribute's address of the parent object.



More information about the Python-list mailing list