[New-bugs-announce] [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([])
>>> f= attrgetter("a", default="b")
>>> f(object())

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>

More information about the New-bugs-announce mailing list