Oct. 8, 2001
7:36 a.m.
[Aahz]
At least with the latter, you can do:
stringtype = (str, unicode) isinstance(x, stringtype)
Hmmmm... Or can you?
Yes -- it's the value of the expression that counts, not how it's spelled. You can even nest these tuples:
int_types = int, long file_types = file, def fori(x): ... return isinstance(x, (int_types, file_types)) ... fori(43) 1 fori(43L) 1 import sys fori(sys.stdin) 1 fori(43.0) 0