instantiate all subclasses of a class

Daniel Nogradi nogradi at gmail.com
Sun Jul 16 11:16:18 EDT 2006


> > >>> from inspect import isclass
> > >>>
> > >>> class x:
> >  ...     def __getattr__( self, attr ):
> >  ...         pass
> >  ...
> > >>> y = x( )
> > >>> isclass( y )
> > True
>
> Which reinforces Michael Spencer's instinct that the inspect.isclass()
> implementation is a bit too clever

Wouldn't the word 'broken' be more appropriate? :)

>
> isinstance(obj, (types.ClassType, type))
>

Thanks a lot this indeed works.



More information about the Python-list mailing list