A new metaclass pattern, class methods

Mike C. Fletcher mcfletch at home.com
Thu May 24 22:11:59 CEST 2001


Why not name those inner classes __call__ so that the resulting regular
classes "Penguin", etceteras are automagically "normal seeming":

class PenguinMeta(BirdMeta):
...
	class __call__(BirdMeta.__call__):
...

aMommaPenguin=Penguin('momma')
aPappaPenguin=Penguin('pappa')
aBabyPenguin=Penguin('baby')

Just a thought,
Mike

-----Original Message-----
From: python-list-admin at python.org
[mailto:python-list-admin at python.org]On Behalf Of Costas Menico
Sent: May 24, 2001 14:55
To: python-list at python.org
Subject: Re: A new metaclass pattern, class methods


Thomas,

I believe I may have a simpler. Please feel free to comment on the
code below.

costas
...
class PenguinMeta(BirdMeta):
...
	class New(BirdMeta.New):
...
#--------------------------------------------------------
# Tests
# Object instantation. Here do anything you want.
aMommaPenguin=Penguin.New('momma')
aPappaPenguin=Penguin.New('pappa')
aBabyPenguin=Penguin.New('baby')
aDog=Dog.New('fido')
...





More information about the Python-list mailing list