"Jacob Lee" <jelee2 at .edu> escribi? en el mensaje
>> things which compesate that (another annoying point>> of Python are slices -- mine are always off by 1).>About slices:
Thank you, but I knew the motivations for this
odd behaviour, which can be found as well in, for
example, MetaFont. However, I disagree.
> satisfy some handy properties, the first of which being:> l[:n] + l[n:] = l
I don't think l[:5] + l[5:] = l is a handy property
and to me is clearly counterintuitive. Further,
I don't understand why l[a:b] has a behaviour which
does't depend on its own logic but on that of certain
constructs containing slices but which aren't the
slices themselves. If you have to add or substract
1 in an expression containing slices (or contained
in a slice), this belongs to the logic of the
expression, not to the slices syntax.
MetaFont explains this by saying that the index
doesn't refer to a character but to a position
between characters, which when traslated to Python
would mean:
s t r i n g
^ ^ ^ ^ ^ ^ ^
0 1 2 3 4 5 6
so that [1:2] is "t".
Javier
___________________________________________________________
Javier Bezos | TeX y tipograf?a
jbezos at wanadoo dot es | http://perso.wanadoo.es/jbezos
............................|...............................
CervanTeX (Spanish TUG) | http://www.cervantex.org