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
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:
# n.py
import m
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 objects follow
#
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
x = m.x( )
y = m.y( )
#
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:
... def __getattr__(
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
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
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