From: mark sparshatt Date: 2005-02-07T19:06:00+09:00 Subject: Re: Classes at runtime Lethalman wrote: > (sorry for my poor English) > Hello, > i can make classes at runtime in Python, just like this: > > class test: pass > class myclass: > def make(self, inherit): > class temp(inherit): pass > return temp() > > instance = myclass().make(test) > > instance is now a class which inherits test... this is a really simple > example but i need to know because i can't do this in ruby. > So, is python more dynamic with objects? Isn't ruby good for this kind > of meta programming? > > Try this class Test end klass = Class.new(Test) p klass.ancestors #=> [#, Test, Object, Kernel] klass is a subclass of Test. HTH -- Mark Sparshatt