[Python-ideas] reprs of recursive datastructures.
ncoghlan at gmail.com
Sat Sep 8 10:16:23 CEST 2012
On Sat, Sep 8, 2012 at 5:45 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> On 08/09/12 16:27, Guido van Rossum wrote:
>> Can someone explain what problem we are trying to solve? I fail to
>> uderstand what's wrong with the current behavior...
> I believe that some people think that if you eval the repr of a
> recursive list, the result should be an equally recursive list.
No, the problem is that you get the *wrong answer* instead of an exception.
>>> x = 
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1
SyntaxError: invalid syntax
>>> x = 
As pointed out earlier, this is due to the fact that the previously
illegal notation used to indicate the recursive reference is now valid
syntax. The simplest fix is to just introduce alternative notation for
the self-reference that will reintroduce the desired syntax error,
such as "<...>" or "<self>".
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas