[Tutor] Keeping a list of attributes of a certain type

Guilherme P. de Freitas guilherme at gpfreitas.com
Fri Jan 15 21:33:11 CET 2010

Thanks everybody for all the suggestions and ideas. I still did not
have time to look them all over, but I will. Thanks again!



On Thu, Jan 14, 2010 at 4:52 AM, Alan Gauld <alan.gauld at btinternet.com> wrote:
> "Guilherme P. de Freitas" <guilherme at gpfreitas.com> wrote
>> Here is my problem. I have two classes, 'Body' and 'Member', and some
>> attributes of 'Body' can be of type 'Member', but some may not. The
>> precise attributes that 'Body' has depend from instance to instance,
>> and they can be added or deleted. I need any instance of 'Body' to
>> keep an up-to-date list of all its attributes that belong to the class
>> 'Member'. How do I do this?
> Check the type of the attribute? Using isinstance()?
> I'm not sure of the rationale - why it needs to know the type etc
> But isinstance is the most obvious way that I can think of.
> Alan G.
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

Guilherme P. de Freitas

More information about the Tutor mailing list