aahz@rahul.net (Aahz Maruch) writes: > [I know we've already reached agreement, but I feel the need to stick my > oar in.] > > Barry A. Warsaw wrote: > > > > NS> Perhaps we could extend isinstance(). How about > > > > NS> isinstance(x, str, unicode) > > > > NS> or > > > > NS> isinstance(x, (str, unicode)) > > > > NS> This is a common problem not limited to string types. I often > > NS> want to test if something is a tuple or a list for example. > > > > That's an interesting idea, but please use the former signature, not > > the latter. > > Ewww, gross, spit spit spit. ;-) > > At least with the latter, you can do: > > stringtype = (str, unicode) > isinstance(x, stringtype) > > Hmmmm... Or can you? Yes, and with the former, you can do stringtype = (str, unicode) isinstance(x, *stringtype) not-that-I-care-ly y'rs M. -- Indeed, when I design my killer language, the identifiers "foo" and "bar" will be reserved words, never used, and not even mentioned in the reference manual. Any program using one will simply dump core without comment. Multitudes will rejoice. -- Tim Peters, 29 Apr 1998
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