Attribute References in Python
Posted
by Jeune
on Stack Overflow
See other posts from Stack Overflow
or by Jeune
Published on 2010-04-17T02:00:02Z
Indexed on
2010/04/17
2:03 UTC
Read the original article
Hit count: 455
python
|object-oriented
I do Java programming and recently started learning Python via the official documentation. I see that we can dynamically add data attributes to an instance object unlike in Java:
class House:
pass
my_house = House()
my_house.number = 40
my_house.rooms = 8
my_house.garden = 1
My question is, in what situations is this feature used? What are the advantages and disadvantages compared to the way it is done in Java?
© Stack Overflow or respective owner