Python "object" as root object
Benno
benjl at cse.unsw.edu.au
Thu May 26 05:41:33 BST 2005
On Wed May 25, 2005 at 23:32:31 -0500, John A Meinel wrote:
>Martin Pool wrote:
>
>>On 25 May 2005, John A Meinel <john at arbash-meinel.com> wrote:
>>
>>
>>>John A Meinel wrote:
>>>
>>>
>>>
>>>>Since you seem to be okay adding it, I will submit a patch. :)
>>>>
>>>>John
>>>>=:->
>>>>
>>>>
>>>>
>>>As promised. Really this is just:
>>>grep -rn "^class.*[^)]:" *
>>>and
>>>sed -e 's/(^class.*[^)]):/\1(object):/'
>>>
>>>(though I used vim for the last part, so my syntax may be a little off).
>>>
>>>It might just be easier for you to do it, it only takes a couple of
>>>seconds.
>>>
>>>
>>
>>OK, done.
>>
>>(It seems that method decorators like classmethod and staticmethod do
>>work ok with old-style classes though.)
>>
>>
>classmethod/staticmethod aren't decorators in the 'decorators' sense.
>They return a new function object. Decorators are something like:
>class myclass:
> @classmethod
> def test(cls, x, y):
> pass
This is just shorthand for:
class myclass:
def test(cls, x, y):
pass
test = classmethod(test)
It is just syntactic sugar to put the modifications to the function up near the
definition, not down at the end of the function. (And pretty nice syntactic sugar
imho.)
New and old don't make any difference to decorators.
Cheers,
Benno
More information about the bazaar
mailing list