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
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
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
Thanks Chris Christian.
Mistery solved :)
Ernest
--
http://mail.python.org/mailman/listinfo/python-list