Re: [Tutor] classes : post-declaration attributes

2013-02-09 Thread neubyr
On Sat, Feb 9, 2013 at 3:24 AM, Alan Gauld wrote: > On 09/02/13 07:01, neubyr wrote: > >> >> I am learning Python 2.7 classes and objects. It seems like attributes >> (data attributes and methods) can be added to a class/object even after >> it's first declaration. For example, >> > > You can do

Re: [Tutor] classes : post-declaration attributes

2013-02-09 Thread Alan Gauld
On 09/02/13 07:01, neubyr wrote: I am learning Python 2.7 classes and objects. It seems like attributes (data attributes and methods) can be added to a class/object even after it's first declaration. For example, You can do that, but mostly you shouldn't. Usually when classes/objects are use

Re: [Tutor] classes : post-declaration attributes

2013-02-08 Thread Steven D'Aprano
On 09/02/13 18:01, neubyr wrote: I understand that all attributes are stored in a dictionary, but I am not following when adding an attribute after initial declaration approach should be used. The official documentation also suggests that valid attributes are all the names present when the class

Re: [Tutor] classes : post-declaration attributes

2013-02-08 Thread Mitya Sirenef
On 02/09/2013 02:01 AM, neubyr wrote: > I am learning Python 2.7 classes and objects. It seems like attributes (data attributes and methods) can be added to a class/object even after it's first declaration. For example, > > > class A(object): > def __init__(self,arg): > self.val1 = arg > > a

[Tutor] classes : post-declaration attributes

2013-02-08 Thread neubyr
I am learning Python 2.7 classes and objects. It seems like attributes (data attributes and methods) can be added to a class/object even after it's first declaration. For example, class A(object): def __init__(self,arg): self.val1 = arg a = A(1) print a.val1 Now another data attribute v