detecting variable types
Chris Green
cmg at dok.org
Wed Sep 22 15:33:01 EDT 2004
"Jay" <wjjeonk at hotmail.com> writes:
> I'm sure this is a really dumb question, but how do you detect a variable
> type in Python?
>
> For example, I want to know if the variable "a" is a list of strings or a
> single string. How do I do this?
>>> type("a")
<type 'str'>
>>> type(1)
<type 'int'>
you should look at the types module as well
>>> type("a") == types.StringType
True
--
Chris Green <cmg at dok.org>
This is my signature. There are many like it but this one is mine.
More information about the Python-list
mailing list