On Jul 26, 7:03 pm, westymatt <[EMAIL PROTECTED]> 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.



A old style class may not have a __new__ attribute, but it's still
callable, right?

class NewStyle(object):
    def __init__(self, old_style_cls):
        self.osc_instance = old_style_cls()
        self.osc_type = type(old_style_cls)
    def introspection(self):
        print "Instrospection shows..."
        print self
        print self.osc_instance
        print self.osc_type

class OldStyle: pass
print type(OldStyle)

ns = NewStyle(OldStyle)
ns.introspection()

--
Hope this helps,
Steven

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to