Alex Martelli wrote:

On 2005 Feb 20, at 17:06, Guido van Rossum wrote:

Oh, bah. That's not what basestring was for. I can't blame you or your
client, but my *intention* was that basestring would *only* be the
base of the two *real* built-in string types (str and unicode).

I think all this just reinforces the notion that LBYL is a bad idea!

The need to check "is this thingy here string-like" is sort of frequent, because strings are sequences which, when iterated on, yield sequences (strings of length 1) which, when iterated on, yield sequences ad infinitum.

Yes, this characteristic of strings is unfortunate because it tends to make some degree of LBYLing unavoidable. I don't think the right solution is to try to come up with safe ways of doing LBYL on strings, though, at least not in the long term.

Maybe in Python 3000 this could be fixed by making strings *not*
be sequences. They would be sliceable, but *not* indexable or
iterable. If you wanted to iterate over their chars, you
would have to say 'for c in s.chars()' or something.

Then you would be able to test whether something is sequence-like
by the presence of __getitem__ or __iter__ methods, without
getting tripped up by strings.

--
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,          | A citizen of NewZealandCorp, a       |
Christchurch, New Zealand          | wholly-owned subsidiary of USA Inc.  |
[EMAIL PROTECTED]          +--------------------------------------+
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to