line break confusion
Piet van Oostrum
piet at cs.uu.nl
Sat Feb 16 16:05:55 CET 2002
>>>>> Michael Mell <mike at nthwave.net> (MM) writes:
MM> In the string module, whitespace = ' \t\n\r\v\f' (5 characters here).
MM> Yet, when I run this:
>>>> import string
>>>> for c in string.whitespace:
>>>> print '.'+ c + '.'
MM> I get 7 results.
MM> What's going on here?
You are counting wrong.
Fist, as aomeone else already noticed, the string contains 6 characters. On
my system they are even in a different order. Try
print string.whitespace.encode('hex') if your python isn't too old.
And then you will get more lines than 6. The \n, \v and \f will probably
get two dots on separate lines each. The \r will rpobably print one dot
only because the second dot overprints the first one. So you should get 11
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum at hccnet.nl
More information about the Python-list