One other note that I'm surprised hasn't been brought up:
In another thread, there is a discussion about what to use as sentinel objects -- often to indicate non-specified parameters, when None is a valid value.
A number of people have proposed using the ellipses as such a value, as it already exists, is built in, is a singleton, has only specialized uses at the moment in different contexts, and is a good mnemonic for "missing".
Apparently a number of people already use it that way.
If Ellipses that does become a standard recommend sentinel object -- that might be a motivator for making it a special word, like None.
However, I"m still a bit confused as to why the rep of the ellipses object isn't it's literal already. Is there any other example of this?
In [1]: repr(list())
Out[1]: '[]'
In [2]: repr(dict())
Out[2]: '{}'
Hmm -- there is set:
In [3]: repr(set())
Out[3]: 'set()'
which breaks eval if you rebind it.
Though it doesn't use the name if it's not empty:
In [16]: s = {1,2,3}
In [17]: repr(s)
Out[17]: '{1, 2, 3}'
In the end, I think this is an argument for not using ellipses as a standard sentinel, rather than an argument for making "Ellipses" more special.
-CHB
Christopher Barker, PhD (Chris)
Python Language Consulting
- Teaching
- Scientific Software Development
- Desktop GUI and Web Development
- wxPython, numpy, scipy, Cython