westymatt wrote: > I have a class where a parameter to its constructor is a type(param) = > 'classobj'. How would I go about instantiating that given it has no > constructor. > Just call the parameter: if it's of type classobj then it's callable, and calling it will create an instance of the class.
>>> class MyClass: ... def __init__(self, a, b): ... self.a = a ... self.b = b ... >>> MyClass <class __main__.MyClass at 0x7ff1ac5c> >>> type(MyClass) <type 'classobj'> >>> def builder(c): ... return c(3, 4) ... >>> builder(MyClass) <__main__.MyClass instance at 0x7ff281cc> >>> regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --------------- Asciimercial ------------------ Get on the web: Blog, lens and tag the Internet Many services currently offer free registration ----------- Thank You for Reading ------------- -- http://mail.python.org/mailman/listinfo/python-list
