Re: Parens do create a tuple

2016-04-11 Thread Random832
On Mon, Apr 11, 2016, at 04:01, Steven D'Aprano wrote: > What tuple that is passed to FunctionType.__call__? > > Where is the tuple in these examples? > > > py> from types import FunctionType > py> FunctionType.__call__(lambda x: x+1, 23) > 24 > py> FunctionType.__call__(lambda x, y: str(x)+str(

Re: Parens do create a tuple

2016-04-11 Thread Steven D'Aprano
On Monday 11 April 2016 15:27, Random832 wrote: > On Mon, Apr 11, 2016, at 00:08, Steven D'Aprano wrote: >> Should we say that the / and - operators therefore create tuples? I don't >> think so. > > But I am talking about the tuple that is passed to FunctionType.__call__ > at runtime, not a tuple

Re: Parens do create a tuple

2016-04-10 Thread Random832
On Mon, Apr 11, 2016, at 00:08, Steven D'Aprano wrote: > Should we say that the / and - operators therefore create tuples? I don't > think so. But I am talking about the tuple that is passed to FunctionType.__call__ at runtime, not a tuple created within some parser stage. -- https://mail.python.

Re: Parens do create a tuple

2016-04-10 Thread Steven D'Aprano
On Mon, 11 Apr 2016 12:51 pm, Random832 wrote: > On Sun, Apr 10, 2016, at 22:32, Steven D'Aprano wrote: >> def func(arg1, arg2, arg3): >> pass >> >> func(1, 2, 3) >> >> does not create a tuple (1, 2, 3) anywhere in its execution. > > Well, the second argument to PyObject_Call and function_c

Re: Parens do create a tuple

2016-04-10 Thread Ben Finney
Steven D'Aprano writes: > On Mon, 11 Apr 2016 11:41 am, Ben Finney wrote: > > > Chris Angelico writes: > > > >> Fair enough. Let's instead say "commas create tuples", which is true > >> in all cases except the singleton empty tuple. Is that near enough > >> that we can avoid the detail? > > >

Re: Parens do create a tuple

2016-04-10 Thread Chris Angelico
On Mon, Apr 11, 2016 at 12:51 PM, Random832 wrote: > On Sun, Apr 10, 2016, at 22:32, Steven D'Aprano wrote: >> def func(arg1, arg2, arg3): >> pass >> >> func(1, 2, 3) >> >> does not create a tuple (1, 2, 3) anywhere in its execution. > > Well, the second argument to PyObject_Call and function_

Re: Parens do create a tuple

2016-04-10 Thread Steven D'Aprano
On Mon, 11 Apr 2016 11:51 am, Chris Angelico wrote: > On Mon, Apr 11, 2016 at 11:41 AM, Ben Finney > wrote: >>> I'd rather be correct on the one-element case and wrong on the empty >>> than the other way around. >> >> To say “commas create tuples” is to say an unobjectionably true >> statement ab

Re: Parens do create a tuple

2016-04-10 Thread Random832
On Sun, Apr 10, 2016, at 22:32, Steven D'Aprano wrote: > def func(arg1, arg2, arg3): > pass > > func(1, 2, 3) > > does not create a tuple (1, 2, 3) anywhere in its execution. Well, the second argument to PyObject_Call and function_call is a tuple, which had to come from somewhere. That may

Re: Parens do create a tuple

2016-04-10 Thread Steven D'Aprano
On Mon, 11 Apr 2016 11:41 am, Ben Finney wrote: > Chris Angelico writes: > >> Fair enough. Let's instead say "commas create tuples", which is true >> in all cases except the singleton empty tuple. Is that near enough >> that we can avoid the detail? > > It's a fine thing to say, because it's si

Re: Parens do create a tuple

2016-04-10 Thread Chris Angelico
On Mon, Apr 11, 2016 at 11:41 AM, Ben Finney wrote: >> I'd rather be correct on the one-element case and wrong on the empty >> than the other way around. > > To say “commas create tuples” is to say an unobjectionably true > statement about Python syntax. It remains true as one continues to learn >

Re: Parens do create a tuple

2016-04-10 Thread Ben Finney
Chris Angelico writes: > Fair enough. Let's instead say "commas create tuples", which is true > in all cases except the singleton empty tuple. Is that near enough > that we can avoid the detail? It's a fine thing to say, because it's simply true. Commas create tuples. There are some tuples that

Re: Parens do create a tuple (was: one-element tuples [Was: Most probably a stupid question, but I still want to ask])

2016-04-10 Thread Tim Chase
On 2016-04-11 10:45, Ben Finney wrote: > Also, there is another obvious way to create an empty tuple: call > the ‘tuple’ type directly: > > >>> foo = tuple() > >>> print(type(foo), len(foo)) > 0 But here the parens make the tuple too: >>> foo = tuple >>> print(type(foo))

Re: Parens do create a tuple (was: one-element tuples [Was: Most probably a stupid question, but I still want to ask])

2016-04-10 Thread Stephen Hansen
On Sun, Apr 10, 2016, at 05:45 PM, Ben Finney wrote: > So, let's please stop saying “parens don't create a tuple”. They do, and > because of that I've stopped saying that false over-simplification. I stand by "parens don't make a tuple", with the caveat that I should have mentioned the empty tuple

Re: Parens do create a tuple

2016-04-10 Thread Chris Angelico
On Mon, Apr 11, 2016 at 10:57 AM, Ben Finney wrote: > Chris Angelico writes: > >> On Mon, Apr 11, 2016 at 10:45 AM, Ben Finney >> wrote: >> > So the expanation that remains true when you examine it is: People >> > wanted a literal syntax to create a zero-length tuple. A pair of parens >> > is t

Re: Parens do create a tuple

2016-04-10 Thread Ben Finney
Chris Angelico writes: > On Mon, Apr 11, 2016 at 10:45 AM, Ben Finney > wrote: > > So the expanation that remains true when you examine it is: People > > wanted a literal syntax to create a zero-length tuple. A pair of parens > > is that literal syntax, and it's the parens that create the (empt

Re: Parens do create a tuple (was: one-element tuples [Was: Most probably a stupid question, but I still want to ask])

2016-04-10 Thread Chris Angelico
On Mon, Apr 11, 2016 at 10:45 AM, Ben Finney wrote: > So the expanation that remains true when you examine it is: People > wanted a literal syntax to create a zero-length tuple. A pair of parens > is that literal syntax, and it's the parens that create the (empty) > tuple. But parens do NOT creat

Parens do create a tuple (was: one-element tuples [Was: Most probably a stupid question, but I still want to ask])

2016-04-10 Thread Ben Finney
Stephen Hansen writes: > […] parens don't make tuples, commas do. Chris Angelico writes: > The thing you're confused at is that it's not the parentheses that > create a tuple. Parentheses merely group. MRAB writes: > As has been said already, it's the comma that makes the tuple. The > par