[Python-ideas] Change repr(Ellipsis) to '...'

dag.odenhall at gmail.com dag.odenhall at gmail.com
Sun Aug 7 14:12:54 CEST 2011


On 7 August 2011 14:01, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On Sun, Aug 7, 2011 at 2:33 PM, Mike Graham <mikegraham at gmail.com> wrote:
>> On Sat, Aug 6, 2011 at 7:21 PM, dag.odenhall at gmail.com
>> <dag.odenhall at gmail.com> wrote:
>>> Now that it is valid in any expressions, I'd argue the repr should
>>> reflect the literal syntax. There are however some reasons this might
>>> not be desirable: ellipsis is used to represent recursive objects, and
>>> by reprlib when summarizing long reprs. Thus there would be ambiguity.
>>> A counter-argument may be that a repr isn't intended to be completely
>>> unambiguous, reversible or parseable - in deed many objects mimic the
>>> literal syntax of builtin types even though they add special behavior.
>>> I was going to give os.environ as an example here, and then learned
>>> this is no longer the case in Python 3, so maybe it is after all seen
>>> as undesirable. :)
>>>
>>> Anyway: discuss!
>>
>> I think the current state is a lot more helpful in debugging, and that
>> making repr(...) be "..." would result in occasional confusion but no
>> positive effects.
>
> Interesting idea, but far too confusing in the interactive interpreter
> and in doctests:
>
> - '...' is also the default prompt for continuation lines (e.g. when
> defining a function)
> - '...' is used to mark 'match anything' sections in doctests
>
> The situation might have been different if the syntax had always been
> allowed everywhere, but there's no compelling reason to change it now.

Strong, valid points; I'd say I'm +/-0 on this proposal myself at this point.



More information about the Python-ideas mailing list