This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: str.format no longer accepts unpacked defaultdict for default values
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: carmenbianca, eric.smith, serhiy.storchaka
Priority: normal Keywords:

Created on 2017-06-07 16:39 by carmenbianca, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg295353 - (view) Author: Carmen Bianca Bakker (carmenbianca) * Date: 2017-06-07 16:39
As brief as can be, the following script works in Python 3.4 and Python 3.5:

    from collections import defaultdict

    mydict = defaultdict(lambda: 'default')

    print('{foo}'.format(**mydict))

And prints "default".

In Python 3.6, you get a KeyError for foo.
msg295364 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-06-07 17:49
There was a bug (see issue18531). It was fixed in 3.6.

Use str.format_map() for formatting with arbitrary mapping.
History
Date User Action Args
2022-04-11 14:58:47adminsetgithub: 74775
2017-06-07 17:49:40serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg295364

resolution: not a bug
stage: resolved
2017-06-07 17:00:55eric.smithsetnosy: + eric.smith
2017-06-07 16:39:08carmenbiancacreate