Very dumb question

Laszlo Zsolt Nagy gandalf at designaproduct.biz
Wed Oct 12 09:45:58 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"
>
>After all, only the last 50 bytes are printed. The string is the same 
>(length 20381) in both cases.
>  
>
Hmm, I checked on Windows now and it is working. But it is bad on 
FreeBSD/Python 2.4.1
Very strange. len(data[:100]) returns 100, but if I try to print it, 
only the first 50 characters printed.

   Les




More information about the Python-list mailing list