Hi Robert,
On Mon, 12 Jul 2010 22:52:24 -0700
Robert Bradshaw <[email protected]> wrote:
> > As for syntax, I think the slice syntax is clever and fairly
> > intuitive. I can also understand using brackets to access operands
> > in an expression. Personally, I think the brackets make more sense
> > for indexing, but they would probably see more use for operand
> > access. It wouldn't bother me to use an ``indexed()`` method
> > instead. I would be happy to review a patch to add either one.
>
> I like the slice syntax as well. I think it'd be nice to reserve the
> __getitem__ notation for subscripts.
We don't have to use __getitem__ to have access to the slice notation.
I suggest keeping __getitem__ to index operands of an expression and
adding an .index property, which provides __getitem__, to get indexed
expressions. For example:
sage: var('x,y,z')
(x, y, z)
sage: t = x+y+z; t
x + y + z
sage: t[0]
x
sage: t[1:]
[y, z]
sage: x.index[i:3] #indexed expression
x.i
Comments?
Cheers,
Burcin
--
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org