Re: Proposed new conditional operator: "or else"

2014-12-03 Thread Chris Angelico
On Wed, Dec 3, 2014 at 10:59 PM, Tim Chase wrote: > On 2014-12-02 23:05, Dennis Lee Bieber wrote: >> > foo == 42 or else >> >> Has a PERL stink to it... like: foo == 42 or die > > This statement actually works in Python and I occasionally use it > when debugging (in the same fashion as one

Re: Proposed new conditional operator: "or else"

2014-12-03 Thread Tim Chase
On 2014-12-02 23:05, Dennis Lee Bieber wrote: > > foo == 42 or else > > Has a PERL stink to it... like: foo == 42 or die This statement actually works in Python and I occasionally use it when debugging (in the same fashion as one might do printf() debugging in C). It raises a NameError a

Re: Proposed new conditional operator: "or else"

2014-12-03 Thread Chris Angelico
On Wed, Dec 3, 2014 at 10:56 PM, Tim Chase wrote: > This actually works in Python and I occasionally use in debugging > (much like finish_sentence() or die ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: Proposed new conditional operator: "or else"

2014-12-03 Thread Tim Chase
On 2014-12-02 23:05, Dennis Lee Bieber wrote: > > foo == 42 or else > > Has a PERL stink to it... like: foo == 42 or die This actually works in Python and I occasionally use in debugging (much like -- https://mail.python.org/mailman/listinfo/python-list

Re: Proposed new conditional operator: "or else"

2014-12-02 Thread Sturla Molden
Dennis Lee Bieber wrote: >> foo == 42 or else >> > > Has a PERL stink to it... like: foo == 42 or die I think this statement needs to take ellipsis as well foo == 42 or else ... Sturls -- https://mail.python.org/mailman/listinfo/python-list

Re: Proposed new conditional operator: "or else"

2014-12-02 Thread Michael Torrie
On 12/02/2014 10:18 AM, Roy Smith wrote: > In the process of refactoring some code, I serendipitously created what I > think is an essential new bit of Python syntax. The “or else” statement. I > ended up with: > > sites_string = args.sites or else self.config['sites'] But isn't that

Re: Proposed new conditional operator: "or else"

2014-12-02 Thread Roy Smith
In article , Chris Angelico wrote: > On Wed, Dec 3, 2014 at 4:41 AM, Zachary Ware > wrote: > > On Tue, Dec 2, 2014 at 11:18 AM, Roy Smith wrote: > >> Wouldn’t it be neat to write: > >> > >>foo == 42 or else > >> > >> and have that be an synonym for: > >> > >> assert foo == 42 > >> >

Re: Proposed new conditional operator: "or else"

2014-12-02 Thread Sturla Molden
Zachary Ware wrote: > On Tue, Dec 2, 2014 at 11:18 AM, Roy Smith wrote: >> Wouldn’t it be neat to write: >> >>foo == 42 or else >> >> and have that be an synonym for: >> >> assert foo == 42 >> >> :-) > > Never going to happen, but I like it! Perhaps raise IntimidationError > instead

Re: Proposed new conditional operator: "or else"

2014-12-02 Thread Andrea D'Amore
On 2014-12-02 17:41:06 +, Zachary Ware said: foo == 42 or else Never going to happen, but I like it! Perhaps raise IntimidationError instead of AssertionError when it fails? That should probably be a DONTPANICError in large, friendly terminal font letters. -- Andrea -- https://mail

Re: Proposed new conditional operator: "or else"

2014-12-02 Thread Marko Rauhamaa
Tim Chase : >> >foo == 42 or else > > In light of the parallel thread discussing the "assert" statement and > the perils of trusting it to be present even though it can be > optimized away, this "or else" could be (in the altered words of Don > Corleone), "I'm gonna make an assertion he can't

Re: Proposed new conditional operator: "or else"

2014-12-02 Thread Tim Chase
On 2014-12-02 11:41, Zachary Ware wrote: > On Tue, Dec 2, 2014 at 11:18 AM, Roy Smith wrote: > > Wouldn’t it be neat to write: > > > >foo == 42 or else > > > > and have that be an synonym for: > > > > assert foo == 42 > > > > :-) > > Never going to happen, but I like it! Perhaps raise >

Re: Proposed new conditional operator: "or else"

2014-12-02 Thread Chris Angelico
On Wed, Dec 3, 2014 at 4:41 AM, Zachary Ware wrote: > On Tue, Dec 2, 2014 at 11:18 AM, Roy Smith wrote: >> Wouldn’t it be neat to write: >> >>foo == 42 or else >> >> and have that be an synonym for: >> >> assert foo == 42 >> >> :-) > > Never going to happen, but I like it! Perhaps raise

Re: Proposed new conditional operator: "or else"

2014-12-02 Thread Ethan Furman
On 12/02/2014 09:41 AM, Zachary Ware wrote: > On Tue, Dec 2, 2014 at 11:18 AM, Roy Smith wrote: >> >> Wouldn’t it be neat to write: >> >>foo == 42 or else >> >> and have that be an synonym for: >> >> assert foo == 42 > > Never going to happen, but I like it! Perhaps raise IntimidationErro

Re: Proposed new conditional operator: "or else"

2014-12-02 Thread Zachary Ware
On Tue, Dec 2, 2014 at 11:18 AM, Roy Smith wrote: > Wouldn’t it be neat to write: > >foo == 42 or else > > and have that be an synonym for: > > assert foo == 42 > > :-) Never going to happen, but I like it! Perhaps raise IntimidationError instead of AssertionError when it fails? -- Zac

Proposed new conditional operator: "or else"

2014-12-02 Thread Roy Smith
In the process of refactoring some code, I serendipitously created what I think is an essential new bit of Python syntax. The “or else” statement. I ended up with: sites_string = args.sites or else self.config['sites'] which, of course, is a syntax error today, but it got me thinking