On Wed, 13 Feb 2013 11:00:15 -0800, stephenwlin wrote:

> Would it be feasible to modify the Python grammar to allow ':' to generate
> slice objects everywhere rather than just indexers and top-level tuples of
> indexers?

If you need to be able to easily construct indexing objects, create a
helper like:

        > class Slicer(object):
        =     def __getitem__(self, s):
        =         return s
        = 
        > s_ = Slicer()
        > s_[1,2,3]
        (1, 2, 3)
        > s_[:]
        slice(None, None, None)
        > s_[1:2:3,4:5:6]
        (slice(1, 2, 3), slice(4, 5, 6))
        > s_[...]
        Ellipsis

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to