__getattribute__ hook and len() problem

2010-07-15 Thread ernest
Hi! I have this class that overrides the __getattribute__ method, so that it returns the attributes of str(self) instead of the attributes of self. class Part(object): def __init__(self): self.content = [] def __str__(self): return str.join('\n', self.content) def

Re: __getattribute__ hook and len() problem

2010-07-15 Thread Chris Rebert
On Thu, Jul 15, 2010 at 5:42 PM, ernest nfdi...@gmail.com wrote: Hi! I have this class that overrides the __getattribute__ method, so that it returns the attributes of str(self) instead of the attributes of self. class Part(object):    def __init__(self):        self.content = []    def

Re: __getattribute__ hook and len() problem

2010-07-15 Thread Christian Heimes
And yet, p.__len__() returns 3. I though len(object) simply called object.__len__. Not exactly, all __magic__ methods of new style classes are called like getattr(type(obj), __len__)(obj). As a result magic methods are never looked up on the object, including hooks like __getattr_() and

Re: __getattribute__ hook and len() problem

2010-07-15 Thread ernest
Thanks Chris Christian. Mistery solved :) Ernest -- http://mail.python.org/mailman/listinfo/python-list