Python "object" as root object

uws uws at xs4all.nl
Fri May 27 13:34:12 BST 2005


På Wed, May 25, 2005 at 10:10:44AM -0500, John A Meinel skrev:
> 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.

This is error-prone and is not needed. It's easy to have all classes in a
module inherit from object by default (so you don't need to subclass object
explicitly) by putting

  __metaclass__ = type

somewhere at the start of the module body.

  mvrgr, Wouter

PS. This is explained in detail in Python In A Nutshell by Alex Martelli,
published by O'Reilly.
-- 
:wq

you keep me alone :: in a room full of friends             -- porcupine tree
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050527/3c8c5b86/attachment.pgp 


More information about the bazaar mailing list