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: keyerror in string format
Type: behavior Stage: resolved
Components: Versions: Python 3.8
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, ezio.melotti, gerryc89, mrabarnett, rhettinger
Priority: normal Keywords:

Created on 2020-01-07 01:01 by gerryc89, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test.py gerryc89, 2020-01-07 01:01 arranged test for recreate the problem, and a workaround
Messages (3)
msg359483 - (view) Author: Gerardo (gerryc89) Date: 2020-01-07 01:01
Hi, i think tha this is a problem, i'm not have mutch experiencing in programming with python. I have added in the file the line that create the problem and a line that make fully functional. Thanks for the time.
Gerry
msg359484 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2020-01-07 01:16
When creating a bug report, please show the actual errors that you get. 

This is not a bug in python. In line 5 you're looking for composer2['third'], so of course you'd need to define it.
msg359485 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2020-01-07 01:19
Instead of doing lookups with square brackets, consider using the dict.get() method that returns a default value rather than raising a KeyError for a missing key.

    composer2[input1]  --> composer2.get(input1, 0)
History
Date User Action Args
2022-04-11 14:59:25adminsetgithub: 83421
2020-01-07 01:19:28rhettingersetnosy: + rhettinger
messages: + msg359485
2020-01-07 01:16:21eric.smithsetstatus: open -> closed

type: compile error -> behavior
components: - Regular Expressions

nosy: + eric.smith
messages: + msg359484
resolution: not a bug
stage: resolved
2020-01-07 01:01:11gerryc89create