alex wrote:
So how can I test if a variable 'a' is either a single character string
or a list?

py> def test(x): ... return (isinstance(x, list) or ... isinstance(x, basestring) and len(x) == 1) ... py> test('a') True py> test('ab') False py> test([]) True py> test(['a', 'b']) True

But definitely read Simon Brunning's post - you probably don't actually want to do this test. Why do you think you want to test this? What's your use case?

STeVe
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to