[issue39715] Implement __repr__ methods for AST classes

2020-10-30 Thread STINNER Victor


STINNER Victor  added the comment:

I reject the feature request.

While repr() on AST nodes could be enhanced for some specific nodes, you have 
to know that the code is mostly implemented in C which make enhancements 
non-trivial. Moreover, this code (Python/Python-ast.c) is generated by a script 
(Parser/asdl_c.py) which makes it even worse to enhance.

I suggest you to develop tooling outside of the stdlib to format an AST tree or 
a list of AST nodes, something like pprint and reprlib modules. It would 
benefit to more Python versions and will give you way more freedom on how to 
format these nodes.

--
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39715] Implement __repr__ methods for AST classes

2020-10-30 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

> I suggest to reject this feature request

+1

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39715] Implement __repr__ methods for AST classes

2020-10-30 Thread STINNER Victor


STINNER Victor  added the comment:

I'm not sure that it's a good idea to make repr(_ast.AST) longer. I suggest to 
reject this feature request. As Serhiy wrote, ast.dump() can already be used.

--
nosy: +vstinner

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39715] Implement __repr__ methods for AST classes

2020-02-27 Thread Brett Cannon


Change by Brett Cannon :


--
nosy:  -brett.cannon

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39715] Implement __repr__ methods for AST classes

2020-02-21 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

For more informative representation you can use ast.dump().

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39715] Implement __repr__ methods for AST classes

2020-02-21 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
nosy: +brett.cannon

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39715] Implement __repr__ methods for AST classes

2020-02-21 Thread Ram Rachum


Ram Rachum  added the comment:

I understand that we have to be really careful in including information that 
could have unlimited size. But I think we have lots of information that isn't 
that way.

For example, for ClassDef and FunctionDef objects, we could include the name. 
For Assign, we could include the lhs. For Import, we could include the module 
name, etc.

And for all objects, we could include the number of descendants that they have, 
so people could more easily understand which are tiny and which are huge.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39715] Implement __repr__ methods for AST classes

2020-02-21 Thread Batuhan Taskaya


Batuhan Taskaya  added the comment:

What kind of repr do you have in your mind? If the repr you are thinking 
contains field information, it would be no-go. Fields of AST objects can 
contain other objects and fields of that objects can contain more objects (this 
goes up to the recursion limit where the child can not be no longer 
calculated). This is why we have ast.dump instead. For small debuggings there 
are 3rd party libraries (e.g: asteria) which adds __repr__ on runtime for 
working on nodes, but on a real application this can cause more problem then it 
benefits.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39715] Implement __repr__ methods for AST classes

2020-02-21 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +BTaskaya, pablogsal

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39715] Implement __repr__ methods for AST classes

2020-02-21 Thread Ram Rachum


New submission from Ram Rachum :

I was playing with the `ast` library today, and it's frustrating to see objects 
like these:

[<_ast.Import object at 0x033FB048>,
 <_ast.Import object at 0x033FB0F0>,
 <_ast.ImportFrom object at 0x033FB160>,
 <_ast.Import object at 0x033FB1D0>,
 <_ast.Assign object at 0x033FB240>,
 <_ast.If object at 0x033FB630>]

A little bit more information about each object in the `__repr__` would make 
this module much easier to work with.

--
components: Library (Lib)
messages: 362419
nosy: cool-RR
priority: normal
severity: normal
status: open
title: Implement __repr__ methods for AST classes
type: enhancement
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com