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: combining dict comprehensing and lists lead to IndexError
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Benjamin Krala, SilentGhost
Priority: normal Keywords:

Created on 2019-04-01 14:25 by Benjamin Krala, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg339293 - (view) Author: Benjamin Krala (Benjamin Krala) Date: 2019-04-01 14:25
Following code snipped leads to an IndexError in the last line.
It basically puts EN_cmw into a dict where is a split on '->'.
It avoid the bug you can change the 1 into -1.
(By definition it shouldnt make a difference)


EN_cmw = '''abandonned->abandoned
 aberation->aberration
 abilityes->abilities
 abilties->abilities
 abilty->ability
 abondon->abandon
 abbout->about
 '''
EN_cmw = EN_cmw.split('\n')
EN_cmw = [string.strip() for string in EN_cmw]


{
    line.split('->')[0]: line.split('->')[1] for line in EN_cmw
}
msg339294 - (view) Author: Benjamin Krala (Benjamin Krala) Date: 2019-04-01 14:26
Correction of typo in the last sentence:

To avoid the bug you can change the 1 into -1
msg339295 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2019-04-01 14:30
IndexError is caused by the fact that split results in an empty list.
History
Date User Action Args
2022-04-11 14:59:13adminsetgithub: 80679
2019-04-01 14:30:11SilentGhostsetstatus: open -> closed

type: compile error -> behavior

nosy: + SilentGhost
messages: + msg339295
resolution: not a bug
stage: resolved
2019-04-01 14:26:56Benjamin Kralasetmessages: + msg339294
2019-04-01 14:25:39Benjamin Kralacreate