Re: [Cheetahtemplate-discuss] creating Python classes
Brought to you by:
rtyler,
tavis_rudd
From: Shannon -jj B. <jj...@gm...> - 2005-03-29 01:05:53
|
>>> # object has to be in the hierarchy so that it is a new-style class. ... class Template(object): ... def bark(self): ... print "woof" ... >>> Page = type("Page", (Template,), {}) >>> Page().bark() woof >>> >>> def meow(self): ... print `self` ... print "meow" ... >>> Page.meow = meow >>> >>> Page().meow() <__main__.Page object at 0xb7d3532c> meow Happy Hacking! -jj On Mon, 28 Mar 2005 16:33:27 -0800 (PST), Tavis Rudd <ta...@da...> wrote: > Hi jj, I don't think I've heard of that approach before. How's it work? > Tavis -- I have decided to switch to Gmail, but messages to my Yahoo account will still get through. |