Re: [Python-Dev] cpython (2.7): note Ellipsis syntax
On 07/30/11 17:00, benjamin.peterson wrote:
http://hg.python.org/cpython/rev/402f94edf11b changeset: 71637:402f94edf11b branch: 2.7 user: Benjamin Peterson <benjamin@python.org> date: Sat Jul 30 09:59:12 2011 -0500 summary: note Ellipsis syntax
files: Doc/library/stdtypes.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2930,7 +2930,7 @@ supports no special operations. There is exactly one ellipsis object, named :const:`Ellipsis` (a built-in name).
-It is written as ``Ellipsis``. +It is written as ``Ellipsis`` or ``...``.
In 2.7, this is not true; ``...`` only works in slices there. Georg
2011/7/30 Georg Brandl <g.brandl@gmx.net>:
On 07/30/11 17:00, benjamin.peterson wrote:
http://hg.python.org/cpython/rev/402f94edf11b changeset: 71637:402f94edf11b branch: 2.7 user: Benjamin Peterson <benjamin@python.org> date: Sat Jul 30 09:59:12 2011 -0500 summary: note Ellipsis syntax
files: Doc/library/stdtypes.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2930,7 +2930,7 @@ supports no special operations. There is exactly one ellipsis object, named :const:`Ellipsis` (a built-in name).
-It is written as ``Ellipsis``. +It is written as ``Ellipsis`` or ``...``.
In 2.7, this is not true; ``...`` only works in slices there.
I know, but why would you use Ellipsis outside of slices? -- Regards, Benjamin
Benjamin Peterson wrote:
why would you use Ellipsis outside of slices?
I could imagine someone wanting to use it as part of a function API. For example, print(a, b, c, ...) would have been a nice way to tell print() not to put a newline on the end. -- Greg
On 07/30/11 19:25, Benjamin Peterson wrote:
2011/7/30 Georg Brandl <g.brandl@gmx.net>:
On 07/30/11 17:00, benjamin.peterson wrote:
http://hg.python.org/cpython/rev/402f94edf11b changeset: 71637:402f94edf11b branch: 2.7 user: Benjamin Peterson <benjamin@python.org> date: Sat Jul 30 09:59:12 2011 -0500 summary: note Ellipsis syntax
files: Doc/library/stdtypes.rst | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2930,7 +2930,7 @@ supports no special operations. There is exactly one ellipsis object, named :const:`Ellipsis` (a built-in name).
-It is written as ``Ellipsis``. +It is written as ``Ellipsis`` or ``...``.
In 2.7, this is not true; ``...`` only works in slices there.
I know, but why would you use Ellipsis outside of slices?
I wouldn't, but that's not the point: the wording as it is now will lead readers to think that they can use the Ellipsis singleton as in Python 3, and they will complain and report bugs about this. (Also, there must have been some reason to make "..." available everywhere for Python 3.) Georg
On Sat, 30 Jul 2011 23:47:36 -0700 Raymond Hettinger <raymond.hettinger@gmail.com> wrote:
(Also, there must have been some reason to make "..." available everywhere for Python 3.)
It's really nice for stub functions:
def foo(x): ...
Using a docstring looks a lot less hackish (and it encourages you to write a doc!): def foo(x): """Some stub function."""
On 31/07/2011 07:47, Raymond Hettinger wrote:
It's really nice for stub functions:
def foo(x): ...
I guess pass is too pass-é? ;-) Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk
On Sun, Jul 31, 2011 at 4:28 PM, Georg Brandl <g.brandl@gmx.net> wrote:
(Also, there must have been some reason to make "..." available everywhere for Python 3.)
Not really - it just let us ditch some special casing in the compilation toolchain that *restricted* it to being used in subscripts (i.e. we were looking at the question from the "is there a good rationale for keeping this arbitrary restriction?" angle). Functionality wise, you could already write 'Ellipsis' everywhere you would otherwise have written '...' and you still have to write ':' as 'slice(None)' outside the context of a subscript operation. Although, as Raymond notes, it can make a nice substitute for 'pass' as a placeholder statement, and can also be used as a placeholder expression. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia
participants (7)
-
Antoine Pitrou
-
Benjamin Peterson
-
Chris Withers
-
Georg Brandl
-
Greg Ewing
-
Nick Coghlan
-
Raymond Hettinger