
May 7, 2011
3:32 p.m.
On 07/05/2011 08:46, Greg Ewing wrote:
Bruce Leban wrote:
I'm opposed to changing int so that int('123_456') ignores the _ as that will change the behavior of existing code and could break apps.
But int('123_456', 0) should perhaps work? (On the grounds that it parses numbers using the same syntax as Python source.)
There's also the argument that if you forbid it then the programmer may have to write: int(string.replace("_", "")) in order to let the user include underscores, which would make it too permissive. If the user entered "_10", the above code would accept it.