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: misbehaviour with map / lambda / isdigit()
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: calvin, drearyslig, tim.peters
Priority: normal Keywords:

Created on 2004-04-23 06:32 by drearyslig, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bug.txt drearyslig, 2004-04-23 06:32 Simple code to reproduce bug
Messages (3)
msg20571 - (view) Author: dreary (drearyslig) Date: 2004-04-23 06:32
This code causes "0".isdigit() to incorrectly report
False. Also apparent on RHEL with Python 2.2.3.
msg20572 - (view) Author: Bastian Kleineidam (calvin) Date: 2004-04-23 12:28
Logged In: YES 
user_id=9205

This is not a bug: the expression ("0".isdigit() and
int("0")) is False, not True as you expected.
What you can do is:
strlist = ['0', '1', '42', 'foo']
intlist = [ int(x) for x in strlist if x.isdigit() ]
msg20573 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2004-04-23 15:04
Logged In: YES 
user_id=31435

Closed as NotABug.  As Calvin said, it's working correctly; the 
and/or trick is delicate.
History
Date User Action Args
2022-04-11 14:56:03adminsetgithub: 40180
2004-04-23 06:32:15drearysligcreate