Re: Argument of the bool function

2011-04-25 Thread Steven D'Aprano
On Mon, 25 Apr 2011 16:26:37 -0700, Paul Rubin wrote: > Chris Angelico writes: >> results = [function() for function in actions] > > results = map(apply, actions) Sadly not in Python 3, where map is lazy and you need to add a call to list to make it equivalent to the list comp. -- Steven -

Re: Argument of the bool function

2011-04-25 Thread Ian Kelly
On Mon, Apr 25, 2011 at 3:28 PM, Thomas Rachel wrote: > Am 25.04.2011 16:29, schrieb Thomas Rachel: > >> or maybe even better (taking care for closures): >> >> function = bool >> value = 'the well at the end of the world' >> ## ... >> actions.append(lambda val=value: function(val)) >> ## ... >> fo

Re: Argument of the bool function

2011-04-25 Thread Paul Rubin
Chris Angelico writes: > results = [function() for function in actions] results = map(apply, actions) -- http://mail.python.org/mailman/listinfo/python-list

Re: Argument of the bool function

2011-04-25 Thread Thomas Rachel
Am 25.04.2011 16:29, schrieb Thomas Rachel: or maybe even better (taking care for closures): function = bool value = 'the well at the end of the world' ## ... actions.append(lambda val=value: function(val)) ## ... for function in actions: results.append(function()) Or yet even better: class

Re: Argument of the bool function

2011-04-25 Thread Chris Angelico
On Tue, Apr 26, 2011 at 12:29 AM, Thomas Rachel wrote: > for function in actions: >     results.append(function()) Can this become: results = [function() for function in actions] Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list

Re: Argument of the bool function

2011-04-25 Thread Thomas Rachel
Am 10.04.2011 18:21, schrieb Mel: Chris Angelico wrote: Who would use keyword arguments with a function that takes only one arg anyway? It's hard to imagine. Maybe somebody trying to generalize function calls (trying to interpret some other language using a python program?) # e.g. input win

Re: Argument of the bool function

2011-04-11 Thread Ethan Furman
Mel wrote: Python is a pragmatic language, so all the rules come pre-broken. +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list

Re: Argument of the bool function

2011-04-10 Thread Ben Finney
Mel writes: > Python is a pragmatic language, so all the rules come pre-broken. +1 QOTW -- \ “Science shows that belief in God is not only obsolete. It is | `\also incoherent.” —Victor J. Stenger, 2001 | _o__)

Re: Argument of the bool function

2011-04-10 Thread Colin J. Williams
On 10-Apr-11 12:21 PM, Mel wrote: Chris Angelico wrote: Who would use keyword arguments with a function that takes only one arg anyway? It's hard to imagine. Maybe somebody trying to generalize function calls (trying to interpret some other language using a python program?) # e.g. input win

Re: Argument of the bool function

2011-04-10 Thread Mel
Chris Angelico wrote: > Who would use keyword arguments with a function that takes only one arg > anyway? It's hard to imagine. Maybe somebody trying to generalize function calls (trying to interpret some other language using a python program?) # e.g. input winds up having the effect of .. fun

Re: Argument of the bool function

2011-04-10 Thread Chris Angelico
On Sun, Apr 10, 2011 at 10:54 PM, candide wrote: > Anyway, passing x as a keyword argument to the bool function appears to be > very rare : i did a regexp search for about 3 source-code Python files > (among them official Python source-code, Django, Sphinx, Eric source-code > and many more sou

Re: Argument of the bool function

2011-04-10 Thread candide
Le 08/04/2011 18:41, Benjamin Kaplan a écrit : bool(x=5) is just passing the value 5 as the argument "x" to the function. Anyway, passing x as a keyword argument to the bool function appears to be very rare : i did a regexp search for about 3 source-code Python files (among them offici

Re: Argument of the bool function

2011-04-09 Thread Robert Kern
On 2011-04-09 23:15 , rusi wrote: On Apr 10, 8:35 am, Grant Edwards wrote: On 2011-04-09, Lie Ryan wrote: On 04/09/11 08:59, candide wrote: Le 09/04/2011 00:03, Ethan Furman a ?crit : > bool([x]) dir([object]) Not very meaningful, isn't it ? The error says it unambiguously, dir()

Re: Argument of the bool function

2011-04-09 Thread rusi
On Apr 10, 8:35 am, Grant Edwards wrote: > On 2011-04-09, Lie Ryan wrote: > > > On 04/09/11 08:59, candide wrote: > >> Le 09/04/2011 00:03, Ethan Furman a ?crit : > > >>>  > bool([x]) > >> dir([object]) > >> Not very meaningful, isn't it ? > > > The error says it unambiguously, dir() does not tak

Re: Argument of the bool function

2011-04-09 Thread Grant Edwards
On 2011-04-09, Lie Ryan wrote: > On 04/09/11 08:59, candide wrote: >> Le 09/04/2011 00:03, Ethan Furman a ?crit : >> >>> > bool([x]) >> dir([object]) >> Not very meaningful, isn't it ? > > The error says it unambiguously, dir() does not take *keyword* > arguments; instead dir() takes *position

Re: Argument of the bool function

2011-04-09 Thread candide
Le 10/04/2011 01:22, Robert Kern a écrit : No one is saying that every instance of "foo([arg])" in the docs means that the given argument is named such that it is available for keyword arguments. What people are saying is that for bool(), *that happens to be the case*. what a piece of luck!

Re: Argument of the bool function

2011-04-09 Thread Robert Kern
On 2011-04-08 17:59 , candide wrote: Le 09/04/2011 00:03, Ethan Furman a écrit : > bool([x]) > Convert a value to a Boolean, using the standard truth testing > procedure. > As you can see, the parameter name is 'x'. OK, your response is clarifying my point ;) I didn't realize that in the

Re: Argument of the bool function

2011-04-08 Thread Lie Ryan
On 04/09/11 08:59, candide wrote: > Le 09/04/2011 00:03, Ethan Furman a écrit : > >> > bool([x]) >> > Convert a value to a Boolean, using the standard truth testing >> > procedure. >> > >> >> As you can see, the parameter name is 'x'. > > > OK, your response is clarifying my point ;) > > >

Re: Argument of the bool function

2011-04-08 Thread candide
Le 09/04/2011 00:03, Ethan Furman a écrit : > bool([x]) > Convert a value to a Boolean, using the standard truth testing > procedure. > As you can see, the parameter name is 'x'. OK, your response is clarifying my point ;) I didn't realize that in the bool([x]) syntax, identifier x ref

Re: Argument of the bool function

2011-04-08 Thread Ben Finney
candide writes: > Le 08/04/2011 18:43, Ian Kelly a écrit : > > In "bool(x=5)", "x=5" is also not an expression. It's passing the > > expression "5" in as the parameter x, using a keyword argument. > > You are probably right but how do you deduce this brilliant > interpretation from the wording g

Re: Argument of the bool function

2011-04-08 Thread Ethan Furman
candide wrote: Le 08/04/2011 18:43, Ian Kelly a écrit : In "bool(x=5)", "x=5" is also not an expression. It's passing the expression "5" in as the parameter x, using a keyword argument. >> You are probably right but how do you deduce this brilliant interpretation from the wording given in th

Re: Argument of the bool function

2011-04-08 Thread candide
Le 08/04/2011 18:43, Ian Kelly a écrit : "x=42" is an assignment statement, not an expression. Right, I was confounding with C ;) In fact, respect to this question, the documentation makes things unambiguous : - In contrast to many other languages, not all language constru

Re: Argument of the bool function

2011-04-08 Thread Mel
candide wrote: > About the standard function bool(), Python's official documentation > tells us the following : > > bool([x]) > Convert a value to a Boolean, using the standard truth testing procedure. > > In this context, what exactly a "value" is referring to ? > > For instance, > >>> x=42 > >

Re: Argument of the bool function

2011-04-08 Thread Ian Kelly
On Fri, Apr 8, 2011 at 10:26 AM, candide wrote: x=42 bool(x=5) > True > > > but _expression_ : > > x=42 > > > has no value. "x=42" is an assignment statement, not an expression. In "bool(x=5)", "x=5" is also not an expression. It's passing the expression "5" in as the parameter x,

Re: Argument of the bool function

2011-04-08 Thread Benjamin Kaplan
On Fri, Apr 8, 2011 at 12:26 PM, candide wrote: > About the standard function bool(), Python's official documentation tells us > the following : > > bool([x]) > Convert a value to a Boolean, using the standard truth testing procedure. > > > In this context, what exactly a "value" is referring to ?

Argument of the bool function

2011-04-08 Thread candide
About the standard function bool(), Python's official documentation tells us the following : bool([x]) Convert a value to a Boolean, using the standard truth testing procedure. In this context, what exactly a "value" is referring to ? For instance, >>> x=42 >>> bool(x=5) True >>> but _ex