argument type
Steven Bethard
steven.bethard at gmail.com
Tue Dec 28 01:57:00 EST 2004
It's me wrote:
> "It's me" <itsme at yahoo.com> wrote in message news:EO6Ad.3296>
>
>>I need to look up and see what:
>>
>> if not isinstance(arg2, basestring):
>>
>>does.
>
> Okay, I got the idea there.
>
> Now, what if arg2 is not a string but either a number or a bunch of numbers?
> Using your method, can I say something to the effect of "if arg2 is *not* an
> instance of a simple number"?
The isinstance function takes either a single type, or a tuple of types,
so you can do something like:
if not isinstance(arg2, (int, long, float)):
or if you want to include strings as well:
if not isinstance(arg2, (basestring, int, long, float)):
Steve
More information about the Python-list
mailing list