class or class-instance ?
Diez B. Roggisch
deets at nospam.web.de
Mon Apr 28 03:36:50 EDT 2008
Stef Mientki schrieb:
> hello,
>
> I've a procedure (or in fact a class method) that should be callable with
> either a class
> (in which case the procedure should create an instance)
> or with an instance of that class
> as the parameter.
>
> def somefunction ( self, parameter ) :
> if parameter is a class, create an instance of that class
> else do nothing
>
>
>
> now I should be able to call the above procedure in either of the
> following ways:
>
> somefunction ( someclass )
>
> or
>
> somefunction ( someclass () )
There is a
isclass
in the module inspect.
Diez
More information about the Python-list
mailing list