Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: eryk sun Newsgroups: comp.lang.python Subject: Re: import locale and print range on same line Date: Sun, 24 Jan 2016 02:00:34 -0600 Lines: 47 Message-ID: References: <2bda88dd-82e3-4e43-b49c-3945a0befdc2@googlegroups.com> <56a37b1e$0$1612$c3e8da3$5496439d@news.astraweb.com> <56a383fa$0$1593$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de GVCnA0jhGk+eoLuPEg8NnAE507JuumyfIOI9SL+CvJjw== 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; 'continuation': 0.07; 'cmd': 0.09; 'subject:same': 0.09; 'unexpected': 0.09; 'python': 0.10; 'jan': 0.11; "'hello": 0.16; '2016': 0.16; '23,': 0.16; '24,': 0.16; 'cmd,': 0.16; 'finicky': 0.16; 'luckily': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'reedy': 0.16; 'shells': 0.16; 'subject:import': 0.16; 'syntaxerror:': 0.16; 'tried:': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'windows': 0.20; 'cc:2**0': 0.20; '"",': 0.22; 'parsing': 0.22; 'am,': 0.23; 'sat,': 0.23; 'header:In-Reply-To:1': 0.24; 'example': 0.26; 'command': 0.26; 'chris': 0.26; 'not.': 0.27; 'message- id:@mail.gmail.com': 0.27; 'omitted': 0.29; 'prints': 0.29; 'character': 0.29; 'print': 0.30; "d'aprano": 0.33; 'steven': 0.33; 'file': 0.34; 'received:google.com': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'closing': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'enough': 0.39; 'to:addr:python.org': 0.40; 'world': 0.64; 'prompt': 0.79; 'continued.': 0.84; 'escaping': 0.84; 'more?': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=0m/+JhaEdDI3skACsAM3QaIXf/dITYySEF5X0VUiY/Y=; b=tN9NCVEXhIaqNdXIqAOaJ/GpsvqKL6QR84d1LTwOzh8YAqhw57ykMtSMixv/gQ3k7g xzqDUX6is179GLcAd6yMoe87+gu3Bk2EEp+R2khturnlYm2pthF5JOckQ4NJHDIxTjLD Arp4Nek729XoEJ05lwkdX8R4+UwKpSinf38swMYaaquptbWgzhY7oZGGKIEVFC112jd/ JpYcPzRn1tkVQfrnOY/LINbnlWHOPv6j02NkDzAf7a3wQX3zozUjUqHHipxZMrulLrYB WWtirjP+NmY2JEyWqCGRonjgXvuqX04QWsunLLdTrOjI3fcYxV5XwNO2lcGvaxt+hTCg 35AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=0m/+JhaEdDI3skACsAM3QaIXf/dITYySEF5X0VUiY/Y=; b=fi9I/nmeDmn1r2pwku9sYeHhNfve+Qeu+SU3t8yfYjSQimAGtf1PEXtIfye9nyOU2n nu4aVb8mkjxHHxOHMBekbM0UvjWXOswWCcPOtXjMrXi68EFz3pJCKyXmy/C4vSxnIQI4 F7GPVXoJXjM5kcTcWQTBjpd03Ad4FNzoIDyoZyVnRHz1tgqFnpDf0iLaDMFoIsEYTSh9 AYchbJ2DuJM0iNlta1v6Am1iInIJ5m+gYfrrnkoWMFuGsSbjqyhHTd5gWVcOpxDusVby lgp/Vohgyexz6yLwC3J2cIBCEtYrK3GaAgaw9iPhLRdubMdMcrkNQevQuPE6FheoPX5/ ehSQ== X-Gm-Message-State: AG10YOTmIG9r3QIUE5sd/yXCqL9mg3GLPKjNwv9DD3SrjvW8F+9PBQs62g3NqGHhgb5n/3pZC7N11ALZkrvINg== X-Received: by 10.50.150.7 with SMTP id ue7mr11779893igb.74.1453622473684; Sun, 24 Jan 2016 00:01:13 -0800 (PST) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:102073 On Sat, Jan 23, 2016 at 8:45 PM, Terry Reedy wrote: > On 1/23/2016 8:58 AM, Chris Angelico wrote: >> On Sun, Jan 24, 2016 at 12:45 AM, Steven D'Aprano >> wrote: >>> [steve@ando ~]$ python -c "for i in range(5): >>>> >>>> print 'hello world' >>>> " >>> >>> hello world >>> hello world >>> hello world >>> hello world >>> hello world >>> [steve@ando ~]$ >> >> Well, not everyone's shells are as awesome as bash... > > Like Windows command prompt is not. I tried: > > C:\Users\Terry>python -c "for i in range(5):\n\tprint('hello world')" > File "", line 1 > for i in range(5):\n print('hello world') > ^ > SyntaxError: unexpected character after line continuation character cmd's parsing can be inscrutably finicky and limited, but luckily enough this example works: C:\>py -2 -c ^ More? "def f(n):^ More? More? for i in range(n):^ More? More? print 'hello world'^ More? More? f(5) hello world hello world hello world hello world hello world cmd prints the "More?" prompt when a line is continued. Note that it's necessary to hit enter again after escaping the first enter. Also, as is usual with cmd, the closing double quote is optional, so I omitted it after f(5).