Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: How to use "while" within the command in -c option of python?

Reply
Thread Tools

Re: How to use "while" within the command in -c option of python?

 
 
Chris Angelico
Guest
Posts: n/a
 
      10-13-2012
On Sun, Oct 14, 2012 at 6:06 AM, Joshua Landau
<> wrote:
> The fact that your proposal can't allow "a=[]\nfor x in range(10):
> a.append(x**a[-2])\nprint(a)" makes it somewhat an incomplete suggestion,
> and code like:
>
>> while True: while True: break; break

>
> is just confusing.


Agreed. However, I don't think there's going to be _any_ perfect
solution for delimiting blocks, short of "from __future__ import
braces".

> I don't want to sound closed, but the options I'm really open to are:
>
> a) It does a limited set of things that make a those things nicer, á la"@"
> b) It does almost everything, minus some carefully-chosen things deemed to
> quirky, á la current newlines (which don't allow "if a: if b: pass")
> c) It does everything that would be possible
>
> Your example falls nicely between a and b, which I do not find particularly
> helpful. Mine attempts a by only applying to "python -c", but would be c if
> it didn't. I find the syntax to horrible for general code, which is why I
> didn't suggest that.
>


Your idea is an extension to the -c parameter that would technically
work, but be fairly hard to manage in anything other than the trivial
case. My idea is an extension to general syntax that would work in all
cases where you aren't trying to put a statement after the end of what
would be an indented block. Both have their limitations, but both
would be - as far as I can see - backward compatible.

ChrisA
 
Reply With Quote
 
 
 
 
Chris Angelico
Guest
Posts: n/a
 
      10-13-2012
On Sun, Oct 14, 2012 at 9:00 AM, Joshua Landau
<> wrote:
> That is also callable from the command-line like so:
>>
>> python -m debrace -c "if a: ${ print(1) $ print(2) $ while b: c() $ if g:
>> ${ pass }$ }$ print(d)"


Wait.... you're pretty much implementing from __future__ import braces?

ChrisA
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Re: How to use "while" within the command in -c option of python? Ned Deily Python 0 10-13-2012 02:17 AM
Re: How to use "while" within the command in -c option of python? Herman Python 0 10-13-2012 12:55 AM
Re: How to use "while" within the command in -c option of python? Dave Angel Python 0 10-13-2012 12:29 AM
How to use "while" within the command in -c option of python? Herman Python 0 10-12-2012 10:51 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57