Issue 36498: combining dict comprehensing and lists lead to IndexError (original) (raw)
Issue36498
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) * ![]() |
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:13 | admin | set | github: 80679 |
2019-04-01 14:30:11 | SilentGhost | set | status: open -> closedtype: compile error -> behaviornosy: + SilentGhostmessages: + resolution: not a bugstage: resolved |
2019-04-01 14:26:56 | Benjamin Krala | set | messages: + |
2019-04-01 14:25:39 | Benjamin Krala | create |