Roy Smith wrote:
> Ben Finney <[EMAIL PROTECTED]> wrote:
>> Currently there's no good duck-typing way to differentiate
>> strings from other sequences.
>
> I suppose you could do something like:
>
> try:
> foo.isalpha
> except AttributeError:
> print "foo is not a string"
Another way:
if getattr (foo, 'isalpha', False):
print 'foo is a string'
Of course now string duck types must have an 'isalpha' and list ones can't,
but that shouldn't matter much.
--
Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net
--
http://mail.python.org/mailman/listinfo/python-list