Re: Question about metaclass

2011-11-01 Thread Makoto Kuwata
On Wed, Nov 2, 2011 at 1:40 PM, Ian Kelly wrote: > > If you want to customize the dict you need to do it in __new__, not > __init__.  By the time __init__ is called, the class has already been > created. > > class MetaClass(type): >    def __new__(mcs, name, bases, dict): >        for k, v in dict

Re: Question about metaclass

2011-11-01 Thread Patrick Maupin
On Nov 1, 11:02 pm, Makoto Kuwata wrote: > Hi, > > I want to define a special class which groups functions, like: > >     class Greepting(FuncGroup): >         def hello():          # no self, no @staticmethod! >             print("Hello!") >         def goodbye():        # no self, no @staticmeth

Re: Question about metaclass

2011-11-01 Thread Ian Kelly
On Tue, Nov 1, 2011 at 10:02 PM, Makoto Kuwata wrote: > I tried the following code which converts instance mthods into > static method automatically, but I don't get result what I want. > (python 2.5.5) > >    import sys >    from types import FunctionType > >    class MetaClass(type): >        de

Question about metaclass

2011-11-01 Thread Makoto Kuwata
Hi, I want to define a special class which groups functions, like: class Greepting(FuncGroup): def hello(): # no self, no @staticmethod! print("Hello!") def goodbye():# no self, no @staticmethod! print("Good Bye!") Geeting.hello():