Very dumb question
Peter Otten
__peter__ at web.de
Wed Oct 12 10:28:57 EDT 2005
Laszlo Zsolt Nagy wrote:
> I have a program with this code fragment:
>
> print len(data)
> print data[:50]
> raise SystemExit
>
> This prints:
>
> 20381
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
>
> But if I change 50 to 51
>
> print len(data)
> print data[:51]
> raise SystemExit
>
> then it prints
>
> 20381
> !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
The closest I can get to your situation is
[on linux]
>>> print "abc\rx"[:4]
abc
>>> print "abc\rx"[:5]
xbc
i. e. a character after a 'carriage return' ('\r') overwrites part of the
string which therefore doesn't seem to grow. Try
print repr(data[:51])
to see what's really in your data string.
Peter
More information about the Python-list
mailing list