On 6/26/2010 2:55 PM, Peter Kleiweg wrote:

PSF is funding work on the email module. Problems with cgi and other internet interfacing modules are the main topic of discussion on py-dev this week.

Some basic text string functions seem to be working on byte
string functions as well, but sometimes they don't, and there's
no rhyme in why it does or doesn't.

     >>>  'abcd'[0] == 'abcd'[:1]
     True
     >>>  b'abcd'[0] == b'abcd'[:1]
     False

Why????

The bytes behavior is the normal behavior for sequences. Indexing produces an element of the sequence (in this case an int) while slicing produce a subseqeunce of the sequence, which is different from an element of the sequence. Try the same with tuples, lists, and ranges.

Strings are anomalous in that indexing produces a subsequence instead of an element (char in this case, which Guido chose for Python not to have).
--
Terry Jan Reedy

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

Reply via email to