How to detect what type a variable is?

Calvin Spealman ironfroggy at gmail.com
Thu Nov 30 03:26:40 CET 2006


On 29 Nov 2006 07:36:26 -0800, Leandro Ardissone <lardissone at gmail.com> wrote:
> Hi,
>
> I want to know what type is a variable.
> For example, I get the contents of an xml but some content is a list or
> a string, and I need to know what type it is.
>
> Thanks
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

In nearly all cases where someone asks this question, the situation
turns out to not call for it at all. Usually you simply aren't
thinking in the language you are using properly. You should usually
know what you are dealing with. If you don't, then either the
different types of objects you might have should be interchangable or
you should create a situation where you dont have such an ambiguality.
Perhaps you could change the design such that you always have a list,
even if its just a list of a single string.

-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://ironfroggy-code.blogspot.com/



More information about the Python-list mailing list