belinda thom a écrit :
> Hi,
>
> I've been using the following hack to determine if a type is acceptable
> and I suspect there is a better way to do it:
>
> e.g.
>
> if type(s) == type("") :
> print "okay, i'm happy you're a string"
if isinstance(s, basestring):
print """
There are very few cases where it makes sens to do such a
test anyway...
"""
> If anyone knows a better way, I'm all ears.
A few special cases excepted (ie your function can accept either a
string or a sequence of strings...), the best thing is usually to not
check types at all...
--
http://mail.python.org/mailman/listinfo/python-list