detecting variable types
Byron
DesertLinux at netscape.net
Wed Sep 22 17:19:26 EDT 2004
Hi Jay,
You can detect the type of a variable by using the "types" module that
comes with Python. Here is how to use it:
>>> import types
>>> name = "Steven"
>>> if type(name) is types.StringType:
print "Yes, name is a string."
Hope this helps,
Byron
---
Jay wrote:
> 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?
>
>
More information about the Python-list
mailing list