Is this a good idea or a waste of time?

Qiangning Hong hongqn at gmail.com
Fri Aug 25 01:37:01 EDT 2006


On 24 Aug 2006 20:53:49 -0700, sjdevnull at yahoo.com <sjdevnull at yahoo.com> wrote:
> That's bad form. If you insist on doing something like this, at least
> use "isinstance(a, str)" instead of typeof.  But even that breaks duck
> typing; if a is a unicode string, that'll fail when the function may
> work fine for unicode strings.

To check both str and unicode, you could use "isinstance(a, basestring)".



More information about the Python-list mailing list