new style class

Tim Chase python.list at tim.thechases.com
Fri Nov 2 07:40:00 EDT 2007


gert wrote:
> On Nov 2, 12:27 pm, Boris Borcic <bbor... at gmail.com> wrote:
>> gert wrote:
>>> class Test(object):
>>>     def execute(self,v):
>>>         return v
>>>     def escape(v):
>>>         return v
>>> if  __name__ == '__main__':
>>>     gert = Test()
>>>     print gert.m1('1')
>>>     print Test.m2('2')
>>> Why doesn't this new style class work in python 2.5.1 ?
>> why should it ?
> 
> I don't know I thought it was supported from 2.2?

I don't recall Python supporting non-existent method-calls (such
as m1/m2 when they aren't actually defined) in ANY version of Python.

But once you change that, you'll likely also want to investigate
the classmethod decorator if you want to create class-methods.

-tkc






More information about the Python-list mailing list