Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'encoding': 0.05; 'output': 0.05; 'startup': 0.05; 'sufficient': 0.05; 'derived': 0.09; 'locale': 0.09; 'none)': 0.09; 'received:internal': 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; 'message-id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:messagingengine.com': 0.16; 'reedy': 0.16; 'wrote:': 0.18; 'slightly': 0.19; 'appears': 0.22; 'import': 0.22; 'skip:l 30': 0.24; 'environment': 0.24; 'question': 0.24; 'switch': 0.26; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; '(this': 0.29; 'am,': 0.29; 'related': 0.29; 'url:mailman': 0.30; 'code': 0.31; '"")': 0.31; 'values.': 0.31; 'url:python': 0.33; '-----': 0.33; 'monday,': 0.33; 'actual': 0.34; "i'd": 0.34; 'received:66': 0.35; 'except': 0.35; 'something': 0.35; 'but': 0.35; 'doubt': 0.36; 'idle': 0.36; 'url:listinfo': 0.36; 'possible': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'should': 0.36; 'email addr:python.org': 0.37; 'received:10': 0.37; 'thank': 0.38; 'nov': 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; 'url:mail': 0.40; 'even': 0.60; 'from:no real name:2**0': 0.61; 'you.': 0.62; 'header:Message-Id:1': 0.63; 're:': 0.63; 'more': 0.64; 'different': 0.65; 'email name:python-list': 0.65; 'subject:. ': 0.67; 'between': 0.67; 'introduce': 0.78; '2014,': 0.84; 'partially': 0.84; 'subject:skip:l 10': 0.84 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= message-id:x-sasl-enc:from:to:mime-version :content-transfer-encoding:content-type:subject:date:in-reply-to :references; s=mesmtp; bh=uopwsB9iSNbhgRI/7UNIsF/ls6U=; b=RGuQqd QOUf9NI+iG+eF4WlnL1fsgxE5eUhr33xVYmqpI1i/utPZAfnCa6f08I+7vgDMj0W 9jiJfeByXlufQitIu4IyxJcPKFAc5tQMtQqqWQe4DJZ9ZCUV3jQcq1lGIg1puiZy 3yUVTdTG2wPpxbnLycZjGKFrYMcpvtVzxbt0M= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:x-sasl-enc:from:to :mime-version:content-transfer-encoding:content-type:subject :date:in-reply-to:references; s=smtpout; bh=uopwsB9iSNbhgRI/7UNI sF/ls6U=; b=gcujqpp/OimLT+VABJdX2UfalmU7pUI8bkrbakfwkpTt3t/O8g2f bSrZan9FTRPCCF6E+S7WR4HNHS0zVMca2BbZSJwf+wf2MXbFBF91z/4cOq9Fomvq kh1cK19q4x0wnA7SSUeP2iHWrkEKr9/1DycjzXfpgOjEpqcNKWtej8w= X-Sasl-Enc: xeTcgbsTaSfRPqmEEtM46OcG/eDJpjGt1nx1FKd1IbBH 1415726320 From: random832@fastmail.us To: python-list@python.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Mailer: MessagingEngine.com Webmail Interface - ajax-9183bd94 Subject: Re: locale.getlocale() in cmd.exe vs. Idle Date: Tue, 11 Nov 2014 12:18:40 -0500 In-Reply-To: <595961668.36331.1415717221155.JavaMail.yahoo@jws10713.mail.gq1.yahoo.com> References: <595961668.36331.1415717221155.JavaMail.yahoo@jws10713.mail.gq1.yahoo.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list 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: 73 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1415726322 news.xs4all.nl 2855 [2001:888:2000:d::a6]:34835 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80536 On Tue, Nov 11, 2014, at 09:47, Albert-Jan Roskam wrote: > ----- 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? setlocale returns the actual value that the locale was set to. (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 > -- > https://mail.python.org/mailman/listinfo/python-list -- Random832