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.setlo cale(locale.LC_ ALL, 'English_United States.1252')
'English_United States.1252'
>>locale.format ('%d', float('22440125 00.0000'), grouping = True)
Traceback (most recent call last):
File "<pyshell#2 8>", line 1, in <module>
locale.format(' %d', float('22440125 00.0000'), grouping = True)
File "C:\Python25\li b\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.forma t('%d', float('22440125 0.0000'), grouping = True)
'224,401,250'
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('2244 012500.0000')), grouping = True)
'2,244,012,500'
Is there an int/long related bug lurking in locale?
Sincerely
Thomas Philips 1 1153
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
Mark This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ksenia Marasanova |
last post by:
Hi,
I have some problems with locale module.
On my workstation, changing locale doesn't have effect:
Python 2.3 (#1, Sep 13 2003, 00:49:11)
on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.setlocale(locale.LC_ALL, 'nl_NL')
|
by: Jorgen Grahn |
last post by:
I'm sitting here with a Debian Linux 'Woody' system with the default Python
2.2 installation, and I want the re module to understand that
re.compile(r'\W+'. re.LOCALE) doesn't match my national, accented
characters.
I don't quite understand how the locale module reasons about these things,
and Python doesn't seem to act as other programs on my system. Bug or my
mistake? Here's my environment:
frailea> env |grep -e LC -e LANG
|
by: Sean Shanny |
last post by:
To all,
Running into an out of memory error on our data warehouse server. This
occurs only with our data from the 'September' section of a large fact
table. The exact same query running over data from August or any prior
month for that matter works fine which is why this is so weird. Note that
June 2004 through today is stored in the same f_pageviews table.
Nothing has changed on the server in the last couple of months. I upgraded...
|
by: A.M |
last post by:
Hi,
Is there any built in feature in Python that can format long integer
123456789 to 12,3456,789 ?
Thank you,
Alan
|
by: |
last post by:
Hi all,
running the following code as an console application:
#include <locale>
#include <iostream>
#include <sstream>
#include <tchar.h>
using namespace std;
| |
by: robert |
last post by:
Why can the default locale not be set by its true name? but only by '' ? :
PythonWin 2.5 (r25:51908, Sep 19 2006, 09:52:17) on win32.
(None, None)
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python25\lib\locale.py", line 476, in setlocale
return _setlocale(category, locale)
Error: unsupported locale setting
|
by: cris |
last post by:
Hi,
I got trouble when I try to change the locale used in a program foo.cc
// ----------------- begin
#include <iostream>
#include <locale>
#include <exception>
using namespace std;
int main(int argc, char** argv)
|
by: Oleg Parashchenko |
last post by:
Hello,
I'm working on an unicode-aware application. I like to use "print" to
debug programs, but in this case it was nightmare. The most popular
result of "print" was:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xXX in position
0: ordinal not in range(128)
I spent two hours fixing it, and I hope it's done. The solution is one
|
by: Donn Ingle |
last post by:
Hello,
I hope someone can illuminate this situation for me.
Here's the nutshell:
1. On start I call locale.setlocale(locale.LC_ALL,''), the getlocale.
2. If this returns "C" or anything without 'utf8' in it, then things start
to go downhill:
2a. The app assumes unicode objects internally. i.e. Whenever there is
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |