[Python-Dev] accumulator display syntax

Alex Martelli aleaxit at yahoo.com
Fri Oct 17 13:03:42 EDT 2003

On Friday 17 October 2003 06:38 pm, Skip Montanaro wrote:
>     Alex> ... just as e.g. foo[ 'va':23:2j, {'zip':'zop'}:45:(3,4) ] ...
> I have absolutely no idea how to interpret this.  Is this existing or
> proposed Python syntax?

Perfectly valid and current existing Python syntax:

>>> class F(object):
...   def __getitem__(self, x): return x
>>> foo=F()
>>> foo[ 'va':23:2j, {'zip':'zop'}:45:(3,4) ]
(slice('va', 23, 2j), slice({'zip': 'zop'}, 45, (3, 4)))

Not particularly _sensible_, mind you, and I hope nobody's yet
written any container that IS to be indexed by such tuples of
slices of multifarious nature.  But, indexing does stretch quite
far in the current Python syntax and semantics (in Python's
*pragmatics* you're supposed to use it far more restrainedly).


More information about the Python-Dev mailing list