471,305 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,305 software developers and data experts.

int/long bug in locale?

To pretty up some numbers stored as strings, I used locale to format
them with commas. I then found the following error:
>>import locale
>>>locale.setlocale(locale.LC_ALL, 'English_United States.1252')
'English_United States.1252'
>>locale.format('%d', float('2244012500.0000'), grouping = True)
Traceback (most recent call last):
File "<pyshell#28>", line 1, in <module>
locale.format('%d', float('2244012500.0000'), grouping = True)
File "C:\Python25\lib\locale.py", line 145, in format
formatted = percent % value
TypeError: int argument required

However, if the number is <= 2**31-1, it works just fine:
>>>locale.format('%d', float('224401250.0000'), grouping = True)

Interestingly, if I first convert the floats to ints, , the function
works just fine, even if the numbers exceed 2**31-1:
>>locale.format('%d', int(float('2244012500.0000')), grouping = True)

Is there an int/long related bug lurking in locale?


Thomas Philips

Aug 28 '07 #1
1 1058
On Aug 28, 10:03 am, tkp...@hotmail.com wrote:
Is there an int/long related bug lurking in locale?
Looks like this has already been reported:

See http://bugs.python.org/issue1742669


Aug 28 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Ksenia Marasanova | last post: by
2 posts views Thread by Jorgen Grahn | last post: by
3 posts views Thread by robert | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.