[issue4124] Patch for adding "default" to itemgetter and attrgetter
Miki Tebeka
report at bugs.python.org
Wed Oct 15 00:07:33 CEST 2008
New submission from Miki Tebeka <miki.tebeka at gmail.com>:
This is a patch for adding "default" keyword to itemgetter and attrgetter.
This way you can do:
>>> f = itemgetter(0, default=1)
>>> f([])
1
>>> f= attrgetter("a", default="b")
>>> f(object())
'b'
>>>
I'm not sure about all the Py_INCREF I've placed there, someone with
more knowledge than me should review the code.
----------
components: Library (Lib)
files: getter.patch
keywords: patch
messages: 74774
nosy: tebeka
severity: normal
status: open
title: Patch for adding "default" to itemgetter and attrgetter
versions: Python 2.7
Added file: http://bugs.python.org/file11793/getter.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4124>
_______________________________________
More information about the Python-bugs-list
mailing list