Re: (test) ? a:b

2014-10-27 Thread ast
Mark Lawrence breamore...@yahoo.co.uk a écrit dans le message de news:mailman.15070.1413978605.18130.python-l...@python.org... Also would you please access this list via https://mail.python.org/mailman/listinfo/python-list or read and action this

Re: (test) ? a:b

2014-10-27 Thread Gregory Ewing
Michael Torrie wrote: As far as I can tell, no BASIC dialect I've looked at (DOS and Linux worlds only), has ever had any logical operators like AND (), OR (||), and NOT (!). They only appear to have bitwise operators (,|,~ C equivalent). The fact that comparison operators returned 0 and -1

Re: (test) ? a:b

2014-10-26 Thread Terry Reedy
On 10/26/2014 12:15 AM, Steven D'Aprano wrote: Ben Finney wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: I suspect that Guido and the core developers disagree with you, since they had the opportunity to fix that in Python 3 and didn't. That doesn't follow; there are

Re: (test) ? a:b

2014-10-26 Thread Ben Finney
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: Do you really not see the connection between counting and summing? Connection? Of course. But I also see a huge distinction. I'm surprised you could misunderstand my position to the extent you think such a question needs to be asked.

Re: (test) ? a:b

2014-10-26 Thread MRAB
On 2014-10-27 00:38, Ben Finney wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: Do you really not see the connection between counting and summing? Connection? Of course. But I also see a huge distinction. I'm surprised you could misunderstand my position to the extent you

Re: (test) ? a:b

2014-10-26 Thread Joshua Landau
On 26 October 2014 01:03, Ben Finney ben+pyt...@benfinney.id.au wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: I suspect that Guido and the core developers disagree with you, since they had the opportunity to fix that in Python 3 and didn't. That doesn't follow; there

Re: (test) ? a:b

2014-10-26 Thread Rustom Mody
On Sunday, October 26, 2014 9:45:22 AM UTC+5:30, Steven D'Aprano wrote: http://legacy.python.org/dev/peps/pep-0285/ snipped Ben Finney wrote: I agree with the decision, because this isn't an issue which often leads to *incorrect* code. But I maintain that it's an unfortunate and

Re: (test) ? a:b

2014-10-26 Thread Ben Finney
Joshua Landau jos...@landau.ws writes: Guido van Rossum answered Jul 28 '11 at 21:20, http://stackoverflow.com/questions/3174392/is-it-pythonic-to-use-bools-as-ints False==0 and True==1, and there's nothing wrong with that. Guido is incorrect. I've already stated what's wrong. That's

Re: (test) ? a:b

2014-10-26 Thread Rustom Mody
On Monday, October 27, 2014 7:59:04 AM UTC+5:30, Ben Finney wrote: Joshua Landau writes: Guido van Rossum answered Jul 28 '11 at 21:20, http://stackoverflow.com/questions/3174392/is-it-pythonic-to-use-bools-as-ints False==0 and True==1, and there's nothing wrong with that. Guido is

Re: (test) ? a:b

2014-10-26 Thread Joshua Landau
On 27 October 2014 02:28, Ben Finney ben+pyt...@benfinney.id.au wrote: Joshua Landau jos...@landau.ws writes: Guido van Rossum answered Jul 28 '11 at 21:20, http://stackoverflow.com/questions/3174392/is-it-pythonic-to-use-bools-as-ints False==0 and True==1, and there's nothing wrong with

Re: (test) ? a:b

2014-10-26 Thread Ben Finney
Joshua Landau jos...@landau.ws writes: On 27 October 2014 02:28, Ben Finney ben+pyt...@benfinney.id.au wrote: Guido is incorrect. I've already stated what's wrong. You were arguing about what Guido thinks. I don't know where I did that; to my knowledge, this is the first time I've mentioned

Re: (test) ? a:b

2014-10-25 Thread Ned Batchelder
On 10/25/14 1:03 AM, Steven D'Aprano wrote: alister wrote: On Fri, 24 Oct 2014 10:20:30 -0700, Dan Stromberg wrote: On Fri, Oct 24, 2014 at 1:38 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I don't get why that's considered hard to read. So why is it hard to read when

Re: (test) ? a:b

2014-10-25 Thread Ian Kelly
On Sat, Oct 25, 2014 at 5:58 AM, Ned Batchelder n...@nedbatchelder.com wrote: You mention standard Python idioms. I think this style of conditional-via-indexing is becoming quite uncommon, and is no longer one of the standard Python idioms. This is now in the category of outdated hack. I

Re: (test) ? a:b

2014-10-25 Thread alister
On Sat, 25 Oct 2014 16:03:16 +1100, Steven D'Aprano wrote: [Alister] I had to mentally step through this before it became apparent what it was doing, can see places where it could be usefull (a switch replacement) but it is not instantly obvious Very little code is instantly obvious. Even

Re: (test) ? a:b

2014-10-25 Thread Ben Finney
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: Of course it won't be clear to *everyone* but it should be clear enough to people who are familiar with standard Python idioms. A concrete example should be more obvious than the fake example: title = ('Mr', 'Ms')[person.sex ==

Re: (test) ? a:b

2014-10-25 Thread Dan Stromberg
On Sat, Oct 25, 2014 at 1:45 PM, Ben Finney ben+pyt...@benfinney.id.au wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: title = ('Mr', 'Ms')[person.sex == 'F'] which should be clear to anyone who understands indexing in Python and that True == 1 and False == 0. I consider

Re: (test) ? a:b

2014-10-25 Thread Ben Finney
Dan Stromberg drsali...@gmail.com writes: EG, if I have 3 mutually exclusive command line options, I'll do something like: if option_a + option_b + option_c != 1: sys.stderr.write('{}: -a, -b and -c are mutually exclusive\n'.format(sys.argv[0])) That is an excellent illustration of why

Re: (test) ? a:b

2014-10-25 Thread Chris Angelico
On Sun, Oct 26, 2014 at 10:53 AM, Ben Finney ben+pyt...@benfinney.id.au wrote: Dan Stromberg drsali...@gmail.com writes: EG, if I have 3 mutually exclusive command line options, I'll do something like: if option_a + option_b + option_c != 1: sys.stderr.write('{}: -a, -b and -c are

Re: (test) ? a:b

2014-10-25 Thread Mark Lawrence
On 26/10/2014 01:01, Chris Angelico wrote: On Sun, Oct 26, 2014 at 10:53 AM, Ben Finney ben+pyt...@benfinney.id.au wrote: Dan Stromberg drsali...@gmail.com writes: EG, if I have 3 mutually exclusive command line options, I'll do something like: if option_a + option_b + option_c != 1:

Re: (test) ? a:b

2014-10-25 Thread Chris Angelico
On Sun, Oct 26, 2014 at 11:09 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: Horrible IMHO, it just doesn't fit in my mind set. Still each to their own. Yeah, the comprehension version is way more explicit (though it probably ought to be a set and a set comp, not a tuple and a list comp), and

Re: (test) ? a:b

2014-10-25 Thread Steven D'Aprano
Ben Finney wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: Of course it won't be clear to *everyone* but it should be clear enough to people who are familiar with standard Python idioms. A concrete example should be more obvious than the fake example: title = ('Mr',

Re: (test) ? a:b

2014-10-25 Thread Ben Finney
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: I suspect that Guido and the core developers disagree with you, since they had the opportunity to fix that in Python 3 and didn't. That doesn't follow; there are numerous warts in Python 2 that were not fixed in Python 3. As I

Re: (test) ? a:b

2014-10-25 Thread Michael Torrie
On 10/22/2014 09:46 PM, Gregory Ewing wrote: Chris Angelico wrote: I've seen much MUCH worse... where multiple conditional expressions get combined arithmetically, and then the result used somewhere... In the days of old-school BASIC it was common to exploit the fact that boolean

Re: (test) ? a:b

2014-10-25 Thread Ben Finney
Ben Finney ben+pyt...@benfinney.id.au writes: This is short and clear and needs no leaking of the underlying bool implementation:: len(True for line in lines if line.strip()) Correction:: len([True for line in lines if line.strip()]) -- \ “Our task must be to free ourselves

Re: (test) ? a:b

2014-10-25 Thread Chris Angelico
On Sun, Oct 26, 2014 at 12:04 PM, Michael Torrie torr...@gmail.com wrote: But you can run into trouble if you tried to use a common python idiom like this: x = read_some_lines() 'returns number of lines read, or zero if none are if not x: print (I couldn't read any lines)

Re: (test) ? a:b

2014-10-25 Thread Michael Torrie
On 10/25/2014 07:20 PM, Chris Angelico wrote: So don't use Python idioms in BASIC. :) Back when I used to write BASIC code, I'd do explicit comparisons with zero for this sort of thing... these days, I'd use Python idioms, but I'd also write Python code :) I think it's indicative that the

Re: (test) ? a:b

2014-10-25 Thread Steven D'Aprano
Ben Finney wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: I suspect that Guido and the core developers disagree with you, since they had the opportunity to fix that in Python 3 and didn't. That doesn't follow; there are numerous warts in Python 2 that were not fixed

Re: (test) ? a:b

2014-10-25 Thread Chris Angelico
On Sun, Oct 26, 2014 at 3:15 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Since the list items exist only to be counted, the actual item used makes no difference. You could use any value at all, or even a different value each time: len([random.random() for line in lines

Re: (test) ? a:b

2014-10-24 Thread ast
48K? Luxury! ZX81 had an option for 64K -- https://mail.python.org/mailman/listinfo/python-list

Re: (test) ? a:b

2014-10-24 Thread Steven D'Aprano
Marko Rauhamaa wrote: BartC b...@freeuk.com: Ah, but what would x = [f, g][cond]() produce? It will select f or g (which should refer to functions), and call one of those depending on cond. That's not a problem. The problem is it will still evaluate both f and g, That's not really

Re: (test) ? a:b

2014-10-24 Thread Chris Angelico
On Fri, Oct 24, 2014 at 7:38 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Of course one can write hard-to-read code using any idiom by sheer weight of complexity or obfuscated naming: value = [some_function(arg)[23]['key'] or another_function.method((x +

Re: (test) ? a:b

2014-10-24 Thread Marko Rauhamaa
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: So why is it hard to read when the index is a flag? value = [f, g][cond]() So, subjectively, which syntax would you prefer: if j 10: j += 1 else: j = 3 or: j = j + 1 if j 10 else 3 or: j = (lambda: 3,

Re: (test) ? a:b

2014-10-24 Thread Steven D'Aprano
Marko Rauhamaa wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info: So why is it hard to read when the index is a flag? value = [f, g][cond]() So, subjectively, which syntax would you prefer: Depends on what else the code is doing. But my personal preference is a red herring:

Re: (test) ? a:b

2014-10-24 Thread Dan Stromberg
On Fri, Oct 24, 2014 at 1:38 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I don't get why that's considered hard to read. So why is it hard to read when the index is a flag? value = [f, g][cond]() It's clear to you, it's clear to me, but is it clear to everyone? I very

Re: (test) ? a:b

2014-10-24 Thread Tobiah
On 10/22/2014 01:29 AM, ast wrote: Hello Is there in Python something like: j = (j = 10) ? 3 : j+1; as in C language ? thx Out of all of the replies, I don't think anyone actually offered the answer: a if condition else b -- https://mail.python.org/mailman/listinfo/python-list

Re: (test) ? a:b

2014-10-24 Thread Chris Angelico
On Sat, Oct 25, 2014 at 4:23 AM, Tobiah t...@tobiah.org wrote: Out of all of the replies, I don't think anyone actually offered the answer: a if condition else b Jean-Michel did, the very first response. ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: (test) ? a:b

2014-10-24 Thread Ian Kelly
On Fri, Oct 24, 2014 at 7:07 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info if j 10: j += 1 else: j = 3 or: j = j + 1 if j 10 else 3 or: j = (lambda: 3, lambda: j + 1)[j 10]() Certainly not the third one. That's needlessly obfuscated for

Re: (test) ? a:b

2014-10-24 Thread Tobiah
On 10/24/2014 10:27 AM, Chris Angelico wrote: On Sat, Oct 25, 2014 at 4:23 AM, Tobiah t...@tobiah.org wrote: Out of all of the replies, I don't think anyone actually offered the answer: a if condition else b Jean-Michel did, the very first response. ChrisA I had to search for it.

Re: (test) ? a:b

2014-10-24 Thread Marko Rauhamaa
Ian Kelly ian.g.ke...@gmail.com: j = (lambda: 3, lambda: j + 1)[j 10]() Yes, the lambda approach falls victim to function calls being slow. That's just a deficiency in the compiler. There's nothing there that prevents the optimizer from translating the expression into the equivalent if

Re: (test) ? a:b

2014-10-24 Thread alister
On Fri, 24 Oct 2014 10:20:30 -0700, Dan Stromberg wrote: On Fri, Oct 24, 2014 at 1:38 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I don't get why that's considered hard to read. So why is it hard to read when the index is a flag? value = [f, g][cond]() It's clear to

Re: (test) ? a:b

2014-10-24 Thread Marko Rauhamaa
alister alister.nospam.w...@ntlworld.com: a = value if condition else another Value is instantly obvious (at least to a native English speaker anyway) And you can go further down that road. For example, you could say things like: die unless everything is OK Marko --

Re: (test) ? a:b

2014-10-24 Thread Steven D'Aprano
alister wrote: On Fri, 24 Oct 2014 10:20:30 -0700, Dan Stromberg wrote: On Fri, Oct 24, 2014 at 1:38 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I don't get why that's considered hard to read. So why is it hard to read when the index is a flag? value = [f,

Re: (test) ? a:b

2014-10-24 Thread Chris Angelico
On Sat, Oct 25, 2014 at 4:03 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Ha! And yet people have, and continue to, complain *bitterly* about the non-standard ordering of Python's ternary if, compared to C, standard if...else syntax, and English. If the syntax is like C,

Re: (test) ? a:b

2014-10-23 Thread MRAB
On 2014-10-23 04:46, Gregory Ewing wrote: Chris Angelico wrote: I've seen much MUCH worse... where multiple conditional expressions get combined arithmetically, and then the result used somewhere... In the days of old-school BASIC it was common to exploit the fact that boolean expressions

Re: (test) ? a:b

2014-10-23 Thread BartC
Dennis Lee Bieber wlfr...@ix.netcom.com wrote in message news:mailman.15097.1414022143.18130.python-l...@python.org... On Wed, 22 Oct 2014 19:08:40 +0100, BartC b...@freeuk.com declaimed the following: Comparing: x = cond ? f() : g(); # C version with x = [f(), g()] [cond] (Should

Re: (test) ? a:b

2014-10-23 Thread Marko Rauhamaa
BartC b...@freeuk.com: Ah, but what would x = [f, g][cond]() produce? It will select f or g (which should refer to functions), and call one of those depending on cond. That's not a problem. The problem is it will still evaluate both f and g, That's not really the problem. The problem

Re: (test) ? a:b

2014-10-23 Thread Ian Kelly
On Thu, Oct 23, 2014 at 7:44 AM, Marko Rauhamaa ma...@pacujo.net wrote: However, the [f, g][cond]() technique is how pure lambda calculus implements conditional branching so it is interesting in its own right. I wasn't aware that lambda calculus had lists and indexing built in. IOW, you can

Re: (test) ? a:b

2014-10-23 Thread Alain Ketterlin
Marko Rauhamaa ma...@pacujo.net writes: BartC b...@freeuk.com: x = [f, g][cond]() It will select f or g (which should refer to functions), and call one of those depending on cond. That's not a problem. The problem is it will still evaluate both f and g, That's not really the problem.

Re: (test) ? a:b

2014-10-23 Thread Marko Rauhamaa
Alain Ketterlin al...@dpt-info.u-strasbg.fr: j = (lambda: 3, lambda: j + 1)[j 10]() This is just a way to delay evaluation *of the potential results*, i.e., instill a bit of lazyness. That's one way to characterize a function, or code in general. That point of view is apparent in

Re: (test) ? a:b

2014-10-22 Thread Jean-Michel Pichavant
- Original Message - From: ast nom...@invalid.com To: python-list@python.org Sent: Wednesday, 22 October, 2014 10:29:43 AM Subject: (test) ? a:b Hello Is there in Python something like: j = (j = 10) ? 3 : j+1; as in C language ? thx j = 3 if j =10 else j+1 Cheers JM

Re: (test) ? a:b

2014-10-22 Thread buscacio
Em quarta-feira, 22 de outubro de 2014 06h29min55s UTC-2, ast escreveu: Hello Is there in Python something like: j = (j = 10) ? 3 : j+1; as in C language ? thx without not: j = [j+1, 3][j=10] with not: j = [3, j+1][not (j=10)] --

Re: (test) ? a:b

2014-10-22 Thread Chris Angelico
On Wed, Oct 22, 2014 at 8:05 PM, busca...@gmail.com wrote: Em quarta-feira, 22 de outubro de 2014 06h29min55s UTC-2, ast escreveu: Hello Is there in Python something like: j = (j = 10) ? 3 : j+1; as in C language ? thx without not: j = [j+1, 3][j=10] with not: j = [3,

Re: (test) ? a:b

2014-10-22 Thread Mark Lawrence
On 22/10/2014 10:05, busca...@gmail.com wrote: Em quarta-feira, 22 de outubro de 2014 06h29min55s UTC-2, ast escreveu: Hello Is there in Python something like: j = (j = 10) ? 3 : j+1; as in C language ? thx without not: j = [j+1, 3][j=10] with not: j = [3, j+1][not (j=10)] The

Re: (test) ? a:b

2014-10-22 Thread ast
busca...@gmail.com a écrit dans le message de news:7839376e-fc27-4299-ae63-4ddf17ef9...@googlegroups.com... Em quarta-feira, 22 de outubro de 2014 06h29min55s UTC-2, ast escreveu: Hello Is there in Python something like: j = (j = 10) ? 3 : j+1; as in C language ? thx without

Re: (test) ? a:b

2014-10-22 Thread Chris Angelico
On Wed, Oct 22, 2014 at 8:16 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: without not: j = [j+1, 3][j=10] with not: j = [3, j+1][not (j=10)] The death penalty should be reintroduced into the UK for two crimes, writing code like the above and using google groups. No no no. Code like

Re: (test) ? a:b

2014-10-22 Thread Ned Batchelder
On 10/22/14 5:05 AM, busca...@gmail.com wrote: Em quarta-feira, 22 de outubro de 2014 06h29min55s UTC-2, ast escreveu: Hello Is there in Python something like: j = (j = 10) ? 3 : j+1; as in C language ? thx without not: j = [j+1, 3][j=10] with not: j = [3, j+1][not (j=10)] Why

Re: (test) ? a:b

2014-10-22 Thread Mark Lawrence
On 22/10/2014 10:27, Chris Angelico wrote: On Wed, Oct 22, 2014 at 8:16 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: without not: j = [j+1, 3][j=10] with not: j = [3, j+1][not (j=10)] The death penalty should be reintroduced into the UK for two crimes, writing code like the above and

Re: (test) ? a:b

2014-10-22 Thread Marko Rauhamaa
Ned Batchelder n...@nedbatchelder.com: Why on earth would you recommend this outdated hack, when there's a true conditional operator? [...] if someone asks for a conditional operator, at least show them one! No good deed goes unpunished. Marko --

Re: (test) ? a:b

2014-10-22 Thread Mark Lawrence
On 22/10/2014 10:14, ast wrote: busca...@gmail.com a écrit dans le message de news:7839376e-fc27-4299-ae63-4ddf17ef9...@googlegroups.com... Em quarta-feira, 22 de outubro de 2014 06h29min55s UTC-2, ast escreveu: Hello Is there in Python something like: j = (j = 10) ? 3 : j+1; as in

Re: (test) ? a:b

2014-10-22 Thread Rustom Mody
On Wednesday, October 22, 2014 5:01:08 PM UTC+5:30, Ned Batchelder wrote: On 10/22/14 5:05 AM, buscacio wrote: Em quarta-feira, 22 de outubro de 2014 06h29min55s UTC-2, ast escreveu: Hello Is there in Python something like: j = (j = 10) ? 3 : j+1; as in C language ? thx without

Re: (test) ? a:b

2014-10-22 Thread alister
On Wed, 22 Oct 2014 12:41:49 +0100, Mark Lawrence wrote: On 22/10/2014 10:27, Chris Angelico wrote: On Wed, Oct 22, 2014 at 8:16 PM, Mark Lawrence breamore...@yahoo.co.uk wrote: without not: j = [j+1, 3][j=10] with not: j = [3, j+1][not (j=10)] The death penalty should be reintroduced

Re: (test) ? a:b

2014-10-22 Thread Chris Angelico
On Thu, Oct 23, 2014 at 2:12 AM, alister alister.nospam.w...@ntlworld.com wrote: Perhaps you're correct. Is there anything worse than looking at a dreadful piece of code that makes no sense at all and knowing that you'd written it six months earlier? looking a a dreadful piece of unreadable

Re: (test) ? a:b

2014-10-22 Thread alister
On Thu, 23 Oct 2014 02:18:42 +1100, Chris Angelico wrote: On Thu, Oct 23, 2014 at 2:12 AM, alister alister.nospam.w...@ntlworld.com wrote: Perhaps you're correct. Is there anything worse than looking at a dreadful piece of code that makes no sense at all and knowing that you'd written it

Re: (test) ? a:b

2014-10-22 Thread Dan Stromberg
On Wed, Oct 22, 2014 at 2:05 AM, busca...@gmail.com wrote: Em quarta-feira, 22 de outubro de 2014 06h29min55s UTC-2, ast escreveu: Hello Is there in Python something like: j = (j = 10) ? 3 : j+1; as in C language ? thx without not: j = [j+1, 3][j=10] with not: j = [3,

Re: (test) ? a:b

2014-10-22 Thread Steven D'Aprano
Ned Batchelder wrote: On 10/22/14 5:05 AM, busca...@gmail.com wrote: without not: j = [j+1, 3][j=10] with not: j = [3, j+1][not (j=10)] Why on earth would you recommend this outdated hack, when there's a true conditional operator? j = 3 if j = 10 else j+1 I think that's a bit

Re: (test) ? a:b

2014-10-22 Thread Chris Angelico
On Thu, Oct 23, 2014 at 3:28 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: It's also a technique easily extensible to more than two values: '01TX'[n % 4] is in my opinion more readable than: i = n % 4 '0' if i == 0 else '1' if i == 1 else 'T' if i == 3 else

Re: (test) ? a:b

2014-10-22 Thread Michael Torrie
On 10/22/2014 05:45 AM, Mark Lawrence wrote: without not: j = [j+1, 3][j=10] with not: j = [3, j+1][not (j=10)] Oh it's a trick ! thx IMHO it's just dreadful. Why people insist on messing around like this I really don't know, it just drives me nuts. This actually was the standard

Re: (test) ? a:b

2014-10-22 Thread alister
On Thu, 23 Oct 2014 03:28:48 +1100, Steven D'Aprano wrote: Why on earth would you recommend this outdated hack, when there's a true conditional operator? j = 3 if j = 10 else j+1 I think that's a bit harsh. Especially since this appears to have been Buscacio's first post here.

Re: (test) ? a:b

2014-10-22 Thread BartC
Rustom Mody rustompm...@gmail.com wrote in message news:7d2ea3c1-504e-4f5c-8338-501b1483d...@googlegroups.com... On Wednesday, October 22, 2014 5:01:08 PM UTC+5:30, Ned Batchelder wrote: On 10/22/14 5:05 AM, buscacio wrote: Em quarta-feira, 22 de outubro de 2014 06h29min55s UTC-2, ast

Re: (test) ? a:b

2014-10-22 Thread Matthew Ruffalo
On 10/22/2014 12:40 PM, Chris Angelico wrote: That's true when it's fundamentally arithmetic. But part of that readability difference is the redundancy in the second one. What if it weren't so redundant? 'Negative' if x 0 else 'Low' if x 10 else 'Mid' if x 20 else 'High' You can't easily

Re: (test) ? a:b

2014-10-22 Thread Chris Angelico
On Thu, Oct 23, 2014 at 5:27 AM, Matthew Ruffalo mm...@case.edu wrote: On 10/22/2014 12:40 PM, Chris Angelico wrote: That's true when it's fundamentally arithmetic. But part of that readability difference is the redundancy in the second one. What if it weren't so redundant? 'Negative' if x

Re: (test) ? a:b

2014-10-22 Thread Ned Batchelder
On 10/22/14 12:28 PM, Steven D'Aprano wrote: Ned Batchelder wrote: On 10/22/14 5:05 AM, busca...@gmail.com wrote: without not: j = [j+1, 3][j=10] with not: j = [3, j+1][not (j=10)] Why on earth would you recommend this outdated hack, when there's a true conditional operator? j = 3

Re: (test) ? a:b

2014-10-22 Thread Steven D'Aprano
Michael Torrie wrote: On 10/22/2014 05:45 AM, Mark Lawrence wrote: without not: j = [j+1, 3][j=10] with not: j = [3, j+1][not (j=10)] Oh it's a trick ! thx IMHO it's just dreadful. Why people insist on messing around like this I really don't know, it just drives me nuts. This

Re: (test) ? a:b

2014-10-22 Thread Gregory Ewing
Chris Angelico wrote: I've seen much MUCH worse... where multiple conditional expressions get combined arithmetically, and then the result used somewhere... In the days of old-school BASIC it was common to exploit the fact that boolean expressions evaluated to 0 or 1 (or -1, depending on your

Re: (test) ? a:b

2014-10-22 Thread Vito De Tullio
Dennis Lee Bieber wrote: x = [f(), g()] [cond] the latter evaluates both f() and g() instead of just one. Apart from being inefficient, it can have unintended side-effects. Ah, but what would x = [f, g][cond]() produce? headache -- By ZeD --