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.

Author steven.daprano
Recipients NetAlien, steven.daprano
Date 2022-01-08.00:41:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1641602515.96.0.262900218565.issue46302@roundup.psfhosted.org>
In-reply-to
Content
> it returns IndexError (instead of "u") if used in a list comprehension

Works as expected inside a list comprehension:

>>> var = "u2"
>>> [var.strip()[0] for i in range(2)]
['u', 'u']

>>> ["ok" for i in range(2) if var.strip()[0] == "u"]
['ok', 'ok']


I am 99.99% certain that you have a bug in your code, but your code is so complicated that it is not obvious at a glance where the bug is. I am strongly tempted to just close this as "Works for me" and tell you to come back and re-open the bug report when you have isolated the issue to a simpler case, but I will resist the temptation for now.
History
Date User Action Args
2022-01-08 00:41:56steven.dapranosetrecipients: + steven.daprano, NetAlien
2022-01-08 00:41:55steven.dapranosetmessageid: <1641602515.96.0.262900218565.issue46302@roundup.psfhosted.org>
2022-01-08 00:41:55steven.dapranolinkissue46302 messages
2022-01-08 00:41:55steven.dapranocreate