Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'encoding': 0.05; 'output': 0.05; 'startup': 0.05; 'sufficient': 0.05; 'derived': 0.09; 'locale': 0.09; 'none)': 0.09; 'try:': 0.09; 'runs': 0.10; 'python': 0.11; 'bug': 0.12; "'''": 0.16; "'');": 0.16; '(none,': 0.16; '(sorry,': 0.16; '__init__.py': 0.16; 'docstrings': 0.16; 'imports': 0.16; 'it),': 0.16; 'matters,': 0.16; 'reedy': 0.16; 'wrote:': 0.18; 'slightly': 0.19; 'appears': 0.22; 'import': 0.22; 'to:name:python-list@python.org': 0.22; 'skip:l 30': 0.24; 'environment': 0.24; 'question': 0.24; 'switch': 0.26; 'header:In- Reply-To:1': 0.27; 'to:2**1': 0.27; 'idea': 0.28; '(this': 0.29; 'am,': 0.29; 'related': 0.29; 'code': 0.31; '"")': 0.31; 'values.': 0.31; '-----': 0.33; 'monday,': 0.33; "i'd": 0.34; 'except': 0.35; 'something': 0.35; 'but': 0.35; 'doubt': 0.36; 'idle': 0.36; 'possible': 0.36; 'hi,': 0.36; 'should': 0.36; 'email addr:python.org': 0.37; 'thank': 0.38; 'same.': 0.38; 'to:addr:python-list': 0.38; 'subject:': 0.39; 'to:addr:python.org': 0.39; 'system.': 0.39; 'skip:p 20': 0.39; 'even': 0.60; 'received:98.137': 0.60; 'you.': 0.62; 're:': 0.63; 'more': 0.64; 'different': 0.65; 'email name:python-list': 0.65; 'subject:. ': 0.67; 'between': 0.67; 'header:Reply-To:1': 0.67; 'received:gq1.yahoo.com': 0.68; 'received:mail.gq1.yahoo.com': 0.68; 'introduce': 0.78; 'partially': 0.84; 'received:bullet.mail.gq1.yahoo.com': 0.84; 'subject:skip:l 10': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1415717224; bh=BxMB2bEpG5pmztTx2QqeZBs9vGcGCOqXmmRElI1hhGo=; h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject; b=QS2sYqeHYDxqRZgNN6fw8Mp88/2Iq5di6xi5OGRdMSrsr2KjudSuWzrrrvr8YKY8CDqYzQL8oc5Ek7+rMiHlz8P0tlwkl+4ldLv/B3nCTWYh37fn6NCmtZgeCLOhjS98EHLftqZsPJi/joAPdgslb9fixYhKrpFKYorm8JtTF51XHfzFpI0Avx7MC2vecB4xYfI/zFS93edRhQ2kotmPfzGZj1HMSCPZnYiHlcXywziZZ0WS+4hZjIo5p6UE2yn3nRWkXUXNrkmrr9f9ZWkR5zPWqhtzZEuSxxyhfx2t770IyzNOpfmEC3aFWlXEsr78SNyiasyDx/b57qBpBcq7Ug== DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s2048; d=yahoo.com; b=hzBPespTn0EtyZ5t09mEBalqkNKXQeOgcD0mkQQPfzCL/n6ZGG3Gw0U98dm1MdUnbTwMfjC2XurxLGoJLdmVC03npq8lJFVZlRIRh+HhLR6Ad5rAf3oNXv/b/pEK4TfRRicK65EcDmxS6e4pnhS7teX3uJpr3R7nwU07PLEmYSHWy3b3w6G3VzmzHABGI2SpyuVZHT8irxrp3GlP88fb38S4kHtEFb0aFkcrwb+fwn0Y/hRo6S+aOue4ArDAhIYr9pn8KvP13u6T2E7fD1tKJO/LUXJimxMOw/I95s3UW+4Z83OHFq51rM0o7fbnVNYQyo+if9wKsfQZVLM2+nDl4A==; X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 964336.45840.bm@omp1041.mail.gq1.yahoo.com X-YMail-OSG: Oa6fI5wVM1lCmTEM0OfY0bp3WhW0R.UmMaCffS2k8rD7DXk7Mzh8Fk2Cr_lHQP6 Q8jVeHB7FKEmCJfO0r.942TJpC2yRHllmjyFpr_1xmN1Is3XQ4jVlUmo8czKK01IdrvhJfm1hfCk IHQX5oaPPh9a8w61rbaLK51i3ukWmta45T4FziQUeSZWZiqCaMp5a29RitNkZeMM0OrFYSVV2KZI eCOzbPI7HrewBOBXYez5y6PeX91jP2WGgsUlM4e3oMWMvs.7WP1CGFPCxJYCI4wn5EiHhbFHJJCb yp6hXlvIJStyozRUPn7Lk5iuo_qy8xgNlQAdRGgZpz6RwLFc8kjLxVb6cPACYND_7nUllxzD1mKl 39zHLa4pG0IL__kkLjT4w8mdc7tfrxWYJ19S6olWTGhoMyq5CsUPthuVGfiZpz6.o7cUNTd52BYD r3iJm.Wji6gg68t.8X4FLFTxr.BscbYnkyu2iKEaP0cGzeVk1InvNACuv2VFTMm6u0dXVY9vyoyd tElKkohMKz7vXdcp_wC1yln5V0Bupy6H5PEsHr3GGOIKD18Vfhek.q_wXh3VD1b005vDXHMo9f0J ACA-- Date: Tue, 11 Nov 2014 14:47:01 +0000 (UTC) From: Albert-Jan Roskam To: Terry Reedy , "python-list@python.org" In-Reply-To: References: Subject: Re: locale.getlocale() in cmd.exe vs. Idle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Albert-Jan Roskam List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 47 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1415717406 news.xs4all.nl 2971 [2001:888:2000:d::a6]:47810 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80526 ----- Original Message ----- > From: Terry Reedy > To: python-list@python.org > Cc: > Sent: Monday, November 10, 2014 9:31 PM > Subject: Re: locale.getlocale() in cmd.exe vs. Idle > > On 11/10/2014 4:22 AM, Albert-Jan Roskam wrote: >> Hi, >> >> Why do I get different output for locale.getlocale() in Idle vs. cmd.exe? > > Idle runs code in an environment that is slightly altered from the > standard python startup environment'. idlelib.IOBinding has this > ''' > # Try setting the locale, so that we can find out > # what encoding to use > try: > import locale > locale.setlocale(locale.LC_CTYPE, "") > ''' Hi Terry, Thank you. Any idea why setlocale (a *setter*) returns something other than None? (this question is not related to the (None, None) thing of getlocale, just curious). Would it be a good idea to put this setlocale line in site.py? Or should it be in __init__.py to make the code more portable? > idlelib.run, which runs in the user-code subprocess, imports IOBinding. > Setting LC_CTYPE is sufficient for getlocale() to not return null values. So then I would have all the locale categories of the 'bare' locale (sorry, I don't know what else I should call it), except for LC_CTYPE, which is derived from my system. So in LC_NUMERIC I'd still have the en_US period/comma for decimal/thousand grouping, respectively, but I switch to the nl_NL LC_CTYPE. I doubt if it matters, but still: will this not introduce an ueber hard-to-find possible bug when I use re.LOCALE? > C:\Users\Terry>python -c "import locale; > print(locale.getlocale())" > > (None, None) > > C:\Users\Terry>python -c "import locale; > locale.setlocale(locale.LC_CTYPE, ''); print(locale.getlocale())" > ('English_United States', '1252') What is the difference between getlocale and getdefaultlocale anyway? The docstrings are even partially the same. The notatation of getlocale appears to be OS-specific ("English_United States" in Windows) and not Unix-like (cf. getdefaultlocale: en_US) regards, Albert-Jan