[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 >>>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4