Type emulation issues with new style classes

Aahz aahz at pythoncraft.com
Sat Feb 28 11:52:59 EST 2004


In article <C0%%b.4538$qX5.249 at nwrdny03.gnilink.net>,
Chris <feb04.20.netman at spamgourmet.com> wrote:
>
>class Z(object):
>    value = 42
>    def __hasattr__(self, name):
>        if name == '__int__':
>            return True
>    def __getattr__(self, name):
>        if name == '__int__':
>            return lambda: self.value

IIRC, __getattribute__ may do what you want, but I don't have time to
check.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Do not taunt happy fun for loops. Do not change lists you are looping over."
--Remco Gerlich, comp.lang.python



More information about the Python-list mailing list