[issue33322] Overridden __getitem__ not called on use of slice syntax when inheriting from tuple
Jacob Thalman
report at bugs.python.org
Sat Apr 21 02:47:32 EDT 2018
New submission from Jacob Thalman <jpthalman at gmail.com>:
class MyTuple(tuple):
def __getitem__(self, item):
print "Getting {}".format(item)
t = MyTuple((1, 2))
t[0] -> "Getting 0"
t[1] -> "Getting 1"
t[slice(None)] -> "Getting slice(None, None, None)"
t[:] -> (1, 2)
t[slice(None, 1)] -> "Getting slice(None, 1, None)"
t[:1] -> (1,)
Overriding __getattribute__ confirms that the overridden __getitem__ is never called when syntactic slice syntax is used.
----------
messages: 315551
nosy: jpthalman
priority: normal
severity: normal
status: open
title: Overridden __getitem__ not called on use of slice syntax when inheriting from tuple
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33322>
_______________________________________
More information about the Python-bugs-list
mailing list