[C++-sig] GNU gettext and "_"
David Abrahams
david.abrahams at rcn.com
Thu Jun 20 16:12:05 CEST 2002
----- Original Message -----
From: "Pearu Peterson" <pearu at cens.ioc.ee>
> > > "Obvious" to me would be to use the same convention as used in Python
> > > slice object, that is,
> > >
> > > x[:y] would be x.slice(None,y)
> > > x[:y:] would be x.slice(None,y,None)
> > > etc.
> >
> > Unfortunately not equivalent.
>
> Read the source code.
I have. Which source are you looking at?
see ceval.c: apply_slice()/assign_slice()
> > >>> range(10)[slice(None:3)]
> > Traceback (most recent call last):
> > File "<stdin>", line 1, in ?
> > TypeError: sequence index must be integer
>
> This example is nonsense. First
> slice(None:3)
> gives syntax error, and second also
> range(10)[slice(1:3)]
> gives
> TypeError: sequence index must be integer
> because index of a list *must* be integer, not a slice or anything else.
Uh, sorry, I meant:
>>> range(10)[slice(None,3)]
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: sequence index must be integer
Anyway:
>>> range(10).__getslice__(None,3)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: an integer is required
So, really, I'm not kidding: None is not a substitute for () where slicing
is concerned.
-Dave
More information about the Cplusplus-sig
mailing list