checking if an object IS in a list
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Fri Jul 18 11:52:26 EDT 2008
On Fri, 18 Jul 2008 07:39:38 -0700, nicolas.pourcelot wrote:
> So, I use something like this in 'sheet.objects.__setattr__(self,
> name, value)':
> if type(value) == Polygon:
> for edge in value.edges:
> if edge is_in sheet.objects.__dict__.itervalues():
> object.__setattr__(self, self.__new_name(), edge)
>
> Ok, I suppose it's confused, but it's difficult to sum up. ;-)
You are setting attributes with computed names? How do you access them?
Always with `gettattr()` or via the `__dict__`? If the answer is yes, why
don't you put the objects the into a dictionary instead of the extra
redirection of an objects `__dict__`?
Oh and the `type()` test smells like you are implementing polymorphism
in a way that should be replaced by OOP techniques.
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list