[Tutor] Re : Is instance of what?

Andre Engels andreengels at gmail.com
Sat Jan 31 18:39:37 CET 2009


On Sat, Jan 31, 2009 at 5:57 PM, Tim Johnson <tim at johnsons-web.com> wrote:
> Using python 2.5.1
>
> If I create a class a
>
> class a:
>
> pass
>
> initialize o as:
>
> o=a
>
> and call
>
> isinstance(o,a)
>
> the return value is True.

Actually, it is false. To make it true, you have to do o=a() rather than o=a

> Is there a function that takes one
>
> argument and returns the class?
>
> Example:
>
> class = whatclass(o)
>
>>> "a"
>
> Since I'm hoping the answer to this question will help me
>
> answer some bigger questions, pointers to relevant docs
>
> and discussions is invited.

o.__class__ (or rather o.__class__.__name__) will work.



--
André Engels, andreengels at gmail.com


More information about the Tutor mailing list