Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #102073

Re: import locale and print range on same line

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From eryk sun <eryksun@gmail.com>
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 <mailman.197.1453622476.15297.python-list@python.org> (permalink)
References <2bda88dd-82e3-4e43-b49c-3945a0befdc2@googlegroups.com> <56a37b1e$0$1612$c3e8da3$5496439d@news.astraweb.com> <mailman.176.1453555148.15297.python-list@python.org> <56a383fa$0$1593$c3e8da3$5496439d@news.astraweb.com> <CAPTjJmqw_C_ju784fPcgOq5zgggOaFR_mwqupzLZd8kN-DOjBw@mail.gmail.com> <n81dsc$co5$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de GVCnA0jhGk+eoLuPEg8NnAE507JuumyfIOI9SL+CvJjw==
Return-Path <eryksun@gmail.com>
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 <n81dsc$co5$1@ger.gmane.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:102073

Show key headers only | View raw


On Sat, Jan 23, 2016 at 8:45 PM, Terry Reedy <tjreedy@udel.edu> wrote:
> On 1/23/2016 8:58 AM, Chris Angelico wrote:
>> On Sun, Jan 24, 2016 at 12:45 AM, Steven D'Aprano <steve@pearwood.info>
>> 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 "<string>", 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).

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

import locale and print range on same line raiwil@gmail.com - 2016-01-23 02:02 -0800
  Re: import locale and print range on same line Marko Rauhamaa <marko@pacujo.net> - 2016-01-23 12:36 +0200
    Re: import locale and print range on same line Vlastimil Brom <vlastimil.brom@gmail.com> - 2016-01-23 12:12 +0100
      Re: import locale and print range on same line Ramo <raiwil@gmail.com> - 2016-01-23 03:57 -0800
  Re: import locale and print range on same line Steven D'Aprano <steve@pearwood.info> - 2016-01-24 00:07 +1100
    Re: import locale and print range on same line Chris Angelico <rosuav@gmail.com> - 2016-01-24 00:19 +1100
      Re: import locale and print range on same line Steven D'Aprano <steve@pearwood.info> - 2016-01-24 00:45 +1100
        Re: import locale and print range on same line Chris Angelico <rosuav@gmail.com> - 2016-01-24 00:58 +1100
          Re: import locale and print range on same line Ramo <raiwil@gmail.com> - 2016-01-23 06:03 -0800
            Re: import locale and print range on same line Chris Angelico <rosuav@gmail.com> - 2016-01-24 01:53 +1100
        Re: import locale and print range on same line Terry Reedy <tjreedy@udel.edu> - 2016-01-23 21:45 -0500
        Re: import locale and print range on same line Chris Angelico <rosuav@gmail.com> - 2016-01-24 13:51 +1100
        Re: import locale and print range on same line eryk sun <eryksun@gmail.com> - 2016-01-24 02:00 -0600

csiph-web