Slicing Issues

Paul McGuire ptmcg at austin.rr._bogus_.com
Sun May 21 17:45:17 EDT 2006


"Heiko Wundram" <me+python at modelnine.org> wrote in message
news:mailman.6047.1148245219.27775.python-list at python.org...
> Am Sonntag 21 Mai 2006 22:52 schrieb BJ Swope:
> >     district_combo=line[85:3]
>
> This returns the slice from character 85 to character 3 in the string,
read
> forwards. Basically, as Python slices are forgiving (because the borders
are
> actually "illogical"), this amounts to nothing, but could also amount
> to: "your indexing boundaries are invalid."
>
> Basically, what you want is:
>
> district_combo = line[85:88]
>
> where 88 = 85 + 3 (3 being the length). Read up on Python slices...
>
> --- Heiko.

How about:

    district_combo=line[85:][:3] ?

-- Paul





More information about the Python-list mailing list