Re: instantiate all subclasses of a class

2006-07-16 Thread Simon Forman
Daniel Nogradi wrote: > > > What is the simplest way to instantiate all classes that are > > > subclasses of a given class in a module? > > > > > > More precisely I have a module m with some content: > > > > > > # m.py > > > class A: > > > pass > > > class x( A ): > > > pass > > > class y(

Re: instantiate all subclasses of a class

2006-07-16 Thread Daniel Nogradi
> > What is the simplest way to instantiate all classes that are > > subclasses of a given class in a module? > > > > More precisely I have a module m with some content: > > > > # m.py > > class A: > > pass > > class x( A ): > > pass > > class y( A ): > > pass > > # all kinds of other o

Re: instantiate all subclasses of a class

2006-07-16 Thread Daniel Nogradi
> > >>> 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 Wou

Re: instantiate all subclasses of a class

2006-07-16 Thread Peter Otten
Daniel Nogradi wrote: > Thanks, this looks pretty good. However there is some wierdness with > isclass: whenever a class has a __getattr__ method an instance of it > will be detected by isclass as a class (although it is not). > > >>> from inspect import isclass > >>> > >>> class x: > ... de

Re: instantiate all subclasses of a class

2006-07-16 Thread Daniel Nogradi
> > More precisely I have a module m with some content: > > > > # m.py > > class A: > > pass > > class x( A ): > > pass > > class y( A ): > > pass > > # all kinds of other objects follow > > # end of m.py > > > > and then in another module I have currently: > > > > # n.py > > import m >

Re: instantiate all subclasses of a class

2006-07-16 Thread Simon Forman
Daniel Nogradi wrote: > What is the simplest way to instantiate all classes that are > subclasses of a given class in a module? > > More precisely I have a module m with some content: > > # m.py > class A: > pass > class x( A ): > pass > class y( A ): > pass > # all kinds of other objec

Re: instantiate all subclasses of a class

2006-07-16 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Daniel Nogradi wrote: > More precisely I have a module m with some content: > > # m.py > class A: > pass > class x( A ): > pass > class y( A ): > pass > # all kinds of other objects follow > # end of m.py > > and then in another module I have currently: > > #

instantiate all subclasses of a class

2006-07-16 Thread Daniel Nogradi
What is the simplest way to instantiate all classes that are subclasses of a given class in a module? More precisely I have a module m with some content: # m.py class A: pass class x( A ): pass class y( A ): pass # all kinds of other objects follow # end of m.py and then in another m