Re: Usefulness of the not in operator

2011-11-06 Thread DevPlayer
On Oct 16, 12:05 am, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: On Sat, 15 Oct 2011 15:04:24 -0700, DevPlayer wrote: I thought x not in y was later added as syntax sugar for not x in y meaning they used the same set of tokens. (Too lazy to check the actual tokens) Stated

Re: Usefulness of the not in operator

2011-10-15 Thread Alexander Kapps
On 10.10.2011 19:29, Nobody wrote: On Sun, 09 Oct 2011 02:25:27 +0200, Alexander Kapps wrote: Even if it's off-topic, could you add some similar explanations for Church numerals (maybe Lambda calculus it isn't too much?) The Church numeral for N is a function of two arguments which applies

Re: Usefulness of the not in operator

2011-10-15 Thread DevPlayer
On Oct 8, 8:41 am, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: candide cand...@free.invalid writes: Python provides     -- the not operator, meaning logical negation     -- the in operator, meaning membership On the other hand, Python provides the not in operator meaning

Re: Usefulness of the not in operator

2011-10-15 Thread Steven D'Aprano
On Sat, 15 Oct 2011 15:04:24 -0700, DevPlayer wrote: 1. I thought x not in y was later added as syntax sugar for not x in y meaning they used the same set of tokens. (Too lazy to check the actual tokens) Whether the compiler has a special token for not in is irrelevant. Perhaps it uses one

Re: Usefulness of the not in operator

2011-10-13 Thread Jussi Piitulainen
Chris Angelico writes: On Sun, Oct 9, 2011 at 12:07 AM, Jussi Piitulainen wrote: But both negations can be avoided by modus tollens. If you are able to start the car, the key is in the ignition. But this translation implies looking at the result and ascertaining the state, which is less

Re: Usefulness of the not in operator

2011-10-11 Thread Steven D'Aprano
Tim Roberts wrote: Westley Martínez aniko...@gmail.com wrote: On Sat, Oct 08, 2011 at 12:34:42PM -0400, Roy Smith wrote: Here's my take on parenthesis: If you need to look up whether they're necessary or not, they are :-) So we don't need precedence charts in the bathroom? Yes, we do,

Re: Usefulness of the not in operator

2011-10-11 Thread Nobody
On Tue, 11 Oct 2011 04:33:43 +1100, Chris Angelico wrote: The Church numeral for N is a function of two arguments which applies its first argument N times to its second, i.e. (f^N)(x) = f(f(...(f(x))...)). Thanks - nice clear explanation. Appreciated. For an encore, can you give an example

Re: Usefulness of the not in operator

2011-10-11 Thread Chris Angelico
On Tue, Oct 11, 2011 at 7:28 PM, Nobody nob...@nowhere.com wrote: It's useful insofar as it allows you to define numbers given nothing other than abstraction and application, which are the only operations available in the lambda calculus. Heh. This is why mathematicians ALWAYS make use of

Re: Usefulness of the not in operator

2011-10-11 Thread Alec Taylor
As you see, this way of writing constants gives you much more poetic freedom than in other programming languages. On Tue, Oct 11, 2011 at 7:46 PM, Chris Angelico ros...@gmail.com wrote: On Tue, Oct 11, 2011 at 7:28 PM, Nobody nob...@nowhere.com wrote: It's useful insofar as it allows you to

Re: Usefulness of the not in operator

2011-10-10 Thread Alexander Kapps
On 08.10.2011 18:08, Steven D'Aprano wrote: Let's define the boolean values and operators using just two functions: [SNIP] Have you just explained Church booleans in an understandable language? Awesome. I still have to chew on this, but I think this is the first time where I might

Re: Usefulness of the not in operator

2011-10-10 Thread John Ladasky
On Oct 8, 5:01 am, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: Who like that second one speaks? Yoda his name is. Programs in Forth he must. -- http://mail.python.org/mailman/listinfo/python-list

Re: Usefulness of the not in operator

2011-10-10 Thread Alec Taylor
On Sun, Oct 9, 2011 at 3:08 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Roy Smith wrote: If you want to take it one step further, all the boolean operators can be derived from nand (the dualists would insist on using nor). Let's define the boolean values and operators

Re: Usefulness of the not in operator

2011-10-10 Thread Alain Ketterlin
Alec Taylor alec.tayl...@gmail.com writes: On Sun, Oct 9, 2011 at 3:08 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: def true(x, y):    return x def false(x, y):    return y [...] def Nand(a, b):    return (lambda c: lambda x, y: c(y, x))(a(b, a)) and we're done.

Re: Usefulness of the not in operator

2011-10-10 Thread Alec Taylor
Unfortunately I don't know lambda [or for that matter, regular] calculus... On Tue, Oct 11, 2011 at 12:01 AM, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: Alec Taylor alec.tayl...@gmail.com writes: On Sun, Oct 9, 2011 at 3:08 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info

Re: Usefulness of the not in operator

2011-10-10 Thread candide
Le 10/10/2011 10:06, John Ladasky a écrit : Who like that second one speaks? Yoda his name is. Programs in Forth he must. ;) We can add to the list : -- Tarzan -- Geronimo -- don Alexandro de la Vega dying in the arms of Zorro ... -- http://mail.python.org/mailman/listinfo/python-list

Re: Usefulness of the not in operator

2011-10-10 Thread Nobody
On Sun, 09 Oct 2011 02:25:27 +0200, Alexander Kapps wrote: Even if it's off-topic, could you add some similar explanations for Church numerals (maybe Lambda calculus it isn't too much?) The Church numeral for N is a function of two arguments which applies its first argument N times to its

Re: Usefulness of the not in operator

2011-10-10 Thread Chris Angelico
On Tue, Oct 11, 2011 at 4:29 AM, Nobody nob...@nowhere.com wrote: The Church numeral for N is a function of two arguments which applies its first argument N times to its second, i.e. (f^N)(x) = f(f(...(f(x))...)). Thanks - nice clear explanation. Appreciated. For an encore, can you give an

Re: Usefulness of the not in operator

2011-10-10 Thread Ian Kelly
On Mon, Oct 10, 2011 at 11:33 AM, Chris Angelico ros...@gmail.com wrote: On Tue, Oct 11, 2011 at 4:29 AM, Nobody nob...@nowhere.com wrote: The Church numeral for N is a function of two arguments which applies its first argument N times to its second, i.e. (f^N)(x) = f(f(...(f(x))...)).

Re: Usefulness of the not in operator

2011-10-10 Thread Terry Reedy
On 10/10/2011 1:55 PM, Ian Kelly wrote: On Mon, Oct 10, 2011 at 11:33 AM, Chris Angelicoros...@gmail.com wrote: On Tue, Oct 11, 2011 at 4:29 AM, Nobodynob...@nowhere.com wrote: The Church numeral for N is a function of two arguments which applies its first argument N times to its second,

Re: Usefulness of the not in operator

2011-10-10 Thread Tim Roberts
Westley Martínez aniko...@gmail.com wrote: On Sat, Oct 08, 2011 at 12:34:42PM -0400, Roy Smith wrote: Here's my take on parenthesis: If you need to look up whether they're necessary or not, they are :-) So we don't need precedence charts in the bathroom? Yes, we do, because I'm always

Re: Usefulness of the not in operator

2011-10-09 Thread Albert van der Horst
In article qotr52nlji7@ruuvi.it.helsinki.fi, Jussi Piitulainen jpiit...@ling.helsinki.fi wrote: Mel writes: Steven D'Aprano wrote: candide wrote: So what is the usefulness of the not in operator ? Recall what Zen of Python tells There should be one-- and preferably only one

Re: Usefulness of the not in operator

2011-10-09 Thread Westley Martínez
On Sat, Oct 08, 2011 at 12:34:42PM -0400, Roy Smith wrote: In article 4e906108$0$27980$426a3...@news.free.fr, candide candide@free.invalid wrote: After browsing source code, I realize that parenthesis are not necessary (not has higher precedence than in). Here's my take on

Usefulness of the not in operator

2011-10-08 Thread candide
'th' not in python False not ('th' in python) False So what is the usefulness of the not in operator ? Recall what Zen of Python tells There should be one-- and preferably only one --obvious way to do it. -- http://mail.python.org/mailman/listinfo/python-list

Re: Usefulness of the not in operator

2011-10-08 Thread Jon Clements
not in expression using only not and in operation. For instance   'th' not in python False   not ('th' in python) False   So what is the usefulness of the not in operator ? Recall what Zen of Python tells There should be one-- and preferably only one --obvious way to do it. You would

Re: Usefulness of the not in operator

2011-10-08 Thread Stefaan Himpe
So what is the usefulness of the not in operator ? Recall what Zen of Python tells There should be one-- and preferably only one --obvious way to do it. the zen of python also says (amongst other things): ... Readability counts. ... Although practicality beats purity ... Best regards

Re: Usefulness of the not in operator

2011-10-08 Thread Steven D'Aprano
candide wrote: So what is the usefulness of the not in operator ? Recall what Zen of Python tells There should be one-- and preferably only one --obvious way to do it. And not in is the obvious way to do it. If the key is not in the ignition, you won't be able to start the car

Re: Usefulness of the not in operator

2011-10-08 Thread Alain Ketterlin
candide candide@free.invalid writes: Python provides -- the not operator, meaning logical negation -- the in operator, meaning membership On the other hand, Python provides the not in operator meaning non-membership. However, it seems we can reformulate any not in expression using

Re: Usefulness of the not in operator

2011-10-08 Thread Mel
Steven D'Aprano wrote: candide wrote: So what is the usefulness of the not in operator ? Recall what Zen of Python tells There should be one-- and preferably only one --obvious way to do it. And not in is the obvious way to do it. If the key is not in the ignition, you won't

Re: Usefulness of the not in operator

2011-10-08 Thread Jussi Piitulainen
Mel writes: Steven D'Aprano wrote: candide wrote: So what is the usefulness of the not in operator ? Recall what Zen of Python tells There should be one-- and preferably only one --obvious way to do it. And not in is the obvious way to do it. If the key

Re: Usefulness of the not in operator

2011-10-08 Thread Roy Smith
In article 87ehyn8xlp@dpt-info.u-strasbg.fr, Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: Sure, but note that you can also reformulate != using not and ==, using not and =, etc. Operators like not in and is not should really be considered single tokens, even though they seem to use

Re: Usefulness of the not in operator

2011-10-08 Thread candide
Le 08/10/2011 14:41, Alain Ketterlin a écrit : Operators like not in and is not should really be considered single tokens, even though they seem to use not. And I think they are really convenient. I realize that I was confused by the lexical form of the not in operator : it is made by

Re: Usefulness of the not in operator

2011-10-08 Thread candide
Le 08/10/2011 14:01, Steven D'Aprano a écrit : And not in is the obvious way to do it. Obvious ? Not so. I performed some code mining and it appears that even good sources make use of not (foo in bar) expressions. begin examples *** from

Re: Usefulness of the not in operator

2011-10-08 Thread candide
Le 08/10/2011 12:42, candide a écrit : not ('th' in python) False After browsing source code, I realize that parenthesis are not necessary (not has higher precedence than in). -- http://mail.python.org/mailman/listinfo/python-list

Re: Usefulness of the not in operator

2011-10-08 Thread Chris Angelico
On Sun, Oct 9, 2011 at 1:40 AM, candide candide@free.invalid wrote: A notin operator or isnot operator would be less confusing (at least in my case ;) ). Let's replace both of them. in -- foo extant bar not in -- foo extinct bar That would solve the problem, wouldn't it? *ducking for cover*

Re: Usefulness of the not in operator

2011-10-08 Thread candide
Le 08/10/2011 12:50, Jon Clements a écrit : 10 - 5 as 10 + -5 (as obviously the - is redundant as an operation), and 10 / 2 as int(10 * .5) or something, who needs a divide!? OK, I see your point but I was supposing non-membershipness seldom needed and in fact one can suppose that test

Re: Usefulness of the not in operator

2011-10-08 Thread Thorsten Kampe
* candide (Sat, 08 Oct 2011 16:41:11 +0200) After browsing source code, I realize that parenthesis are not necessary (not has higher precedence than in). Lower precedence. Thorsten -- http://mail.python.org/mailman/listinfo/python-list

Re: Usefulness of the not in operator

2011-10-08 Thread Dave Angel
On 01/-10/-28163 02:59 PM, candide wrote: Le 08/10/2011 12:42, candide a écrit : not ('th' in python) False After browsing source code, I realize that parenthesis are not necessary (not has higher precedence than in). You should say ... parenthesis are not necessary (not has

Re: Usefulness of the not in operator

2011-10-08 Thread candide
Le 08/10/2011 17:13, Thorsten Kampe a écrit : * candide (Sat, 08 Oct 2011 16:41:11 +0200) After browsing source code, I realize that parenthesis are not necessary (not has higher precedence than in). Lower precedence. Ooops, thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: Usefulness of the not in operator

2011-10-08 Thread Chris Angelico
On Sun, Oct 9, 2011 at 2:16 AM, Dave Angel d...@davea.name wrote: You should say    ... parenthesis are not necessary (not has LOWER precedence than in). Is are not an operator in English, or should this be not parentheses are necessary? ChrisA --

Re: Usefulness of the not in operator

2011-10-08 Thread Grant Edwards
On 2011-10-08, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: candide wrote: So what is the usefulness of the not in operator ? Recall what Zen of Python tells There should be one-- and preferably only one --obvious way to do it. And not in is the obvious way to do

Re: Usefulness of the not in operator

2011-10-08 Thread Steven D'Aprano
Roy Smith wrote: If you want to take it one step further, all the boolean operators can be derived from nand (the dualists would insist on using nor). Let's define the boolean values and operators using just two functions: def true(x, y): return x def false(x, y): return y That's

Re: Usefulness of the not in operator

2011-10-08 Thread candide
Le 08/10/2011 17:16, Dave Angel a écrit : You should say ... parenthesis are not necessary (not has LOWER precedence than in). I should, yes, I confess ;) In my defense, I must tell that Python document reference here : http://docs.python.org/reference/expressions.html#summary has an

Re: Usefulness of the not in operator

2011-10-08 Thread Steven D'Aprano
candide wrote: Le 08/10/2011 14:01, Steven D'Aprano a écrit : And not in is the obvious way to do it. Obvious ? Not so. I performed some code mining and it appears that even good sources make use of not (foo in bar) expressions. All that proves is that even expert Python developers

Re: Usefulness of the not in operator

2011-10-08 Thread Roy Smith
In article 4e906108$0$27980$426a3...@news.free.fr, candide candide@free.invalid wrote: After browsing source code, I realize that parenthesis are not necessary (not has higher precedence than in). Here's my take on parenthesis: If you need to look up whether they're necessary or not, they

Re: Usefulness of the not in operator

2011-10-08 Thread rusi
On Oct 8, 6:31 pm, Roy Smith r...@panix.com wrote: In article 87ehyn8xlp@dpt-info.u-strasbg.fr,  Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: Sure, but note that you can also reformulate != using not and ==, using not and =, etc. Operators like not in and is not should really

Re: Usefulness of the not in operator

2011-10-08 Thread Chris Angelico
On Sun, Oct 9, 2011 at 3:31 AM, rusi rustompm...@gmail.com wrote: If you want to take it one step further, all the boolean operators can be derived from nand (the dualists would insist on using nor).                         I'm not sure what you're questioning, but it's

Re: Usefulness of the not in operator

2011-10-08 Thread Roy Smith
In article acd018ad-8428-4c3d-8aa0-15c4a410f...@x31g2000prd.googlegroups.com, rusi rustompm...@gmail.com wrote: On Oct 8, 6:31 pm, Roy Smith r...@panix.com wrote: In article 87ehyn8xlp@dpt-info.u-strasbg.fr,  Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote: Sure, but note that

Re: Usefulness of the not in operator

2011-10-08 Thread Tim Roberts
Roy Smith r...@panix.com wrote: In article 4e906108$0$27980$426a3...@news.free.fr, candide candide@free.invalid wrote: After browsing source code, I realize that parenthesis are not necessary (not has higher precedence than in). Here's my take on parenthesis: If you need to look up whether

Re: Usefulness of the not in operator

2011-10-08 Thread Alexander Kapps
On 09.10.2011 01:35, Tim Roberts wrote: Roy Smithr...@panix.com wrote: In article4e906108$0$27980$426a3...@news.free.fr, candidecandide@free.invalid wrote: After browsing source code, I realize that parenthesis are not necessary (not has higher precedence than in). Here's my take on

Re: Usefulness of the not in operator

2011-10-08 Thread Chris Angelico
I sent this email twelve hours ago but to the wrong mailing list *blush*. Since nobody else has raised the point, I'll repost it. On Sun, Oct 9, 2011 at 12:07 AM, Jussi Piitulainen jpiit...@ling.helsinki.fi wrote: But both negations can be avoided by modus tollens. If you are able to start the

Re: Usefulness of the not in operator

2011-10-08 Thread Roy Smith
In article mailman.1841.1318123788.27778.python-l...@python.org, Chris Angelico ros...@gmail.com wrote: I sent this email twelve hours ago but to the wrong mailing list *blush*. Since nobody else has raised the point, I'll repost it. On Sun, Oct 9, 2011 at 12:07 AM, Jussi Piitulainen