[Tutor] classes : post-declaration attributes
neubyr
neubyr at gmail.com
Sat Feb 9 21:04:25 CET 2013
On Sat, Feb 9, 2013 at 3:24 AM, Alan Gauld <alan.gauld at btinternet.com>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 that, but mostly you shouldn't.
>
> Usually when classes/objects are used like that its where the object is
> just being used as a data container rather than a true object (with
> behaviour and supporting data). Often a straight dictionary is a better
> option.
>
> Python allows us lots of freedom in how we use it with many unusual
> features. Not all of those things are advisable to use in day to day
> programming. But very occasionally you find a case where they help.
> In general, beginners should avoid them.
>
>
>
Thanks for the reply Alan, Steven and Mitya. That's helpful.
--
N
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130209/8df41fdd/attachment.html>
More information about the Tutor
mailing list