[Python-Dev] Re: Exposing Tools/parser/unparse.py in the stdlib?

2019-11-20 Thread Pablo Galindo Salgado
Opened https://bugs.python.org/issue38870 to track this. On Tue, 19 Nov 2019 at 00:40, Pablo Galindo Salgado wrote: > Hi, > > What do people feel about exposing Tools/parser/unparse.py in the standard > library? Here is my initial rationale: > > * The tool already needs to be maintained and

[Python-Dev] Re: Exposing Tools/parser/unparse.py in the stdlib?

2019-11-20 Thread Nick Coghlan
On Thu., 21 Nov. 2019, 3:30 am Brett Cannon, wrote: > Victor Stinner wrote: > > > It's mostly to minimize the number of imports on "import ast". unparse > > requires extra imports like tokenize which has also tons of > > dependencies. > > Why are you specifically worried about that? If you're

[Python-Dev] Re: Exposing Tools/parser/unparse.py in the stdlib?

2019-11-20 Thread Brett Cannon
Victor Stinner wrote: > Le mar. 19 nov. 2019 à 22:12, Pablo Galindo Salgado > pablog...@gmail.com a écrit : > > Float infinity > > is replaced with 1e309. Again, maybe someone wants > > to render this differently? It sounds like an arbitrary choice (which > > "works" as expected). > > That is not

[Python-Dev] Re: Exposing Tools/parser/unparse.py in the stdlib?

2019-11-19 Thread Batuhan Taskaya
Yes, there is a to_source function which allows AST to source conversation. On Wed, Nov 20, 2019, 9:02 AM Guido van Rossum wrote: > On Tue, Nov 19, 2019 at 10:24 PM Nathaniel Smith wrote: > >> On Mon, Nov 18, 2019 at 4:41 PM Pablo Galindo Salgado >> wrote: >> > >> > Hi, >> > >> > What do

[Python-Dev] Re: Exposing Tools/parser/unparse.py in the stdlib?

2019-11-19 Thread Guido van Rossum
On Tue, Nov 19, 2019 at 10:24 PM Nathaniel Smith wrote: > On Mon, Nov 18, 2019 at 4:41 PM Pablo Galindo Salgado > wrote: > > > > Hi, > > > > What do people feel about exposing Tools/parser/unparse.py in the > standard library? Here is my initial rationale: > > > > * The tool already needs to be

[Python-Dev] Re: Exposing Tools/parser/unparse.py in the stdlib?

2019-11-19 Thread Ivan Levkivskyi
Just wanted to add my +1 to this idea. Moving it to ast module will add little maintenance costs, but will make it easier to use. -- Ivan On Tue, 19 Nov 2019 at 00:46, Pablo Galindo Salgado wrote: > Hi, > > What do people feel about exposing Tools/parser/unparse.py in the standard > library?

[Python-Dev] Re: Exposing Tools/parser/unparse.py in the stdlib?

2019-11-19 Thread Victor Stinner
Le mar. 19 nov. 2019 à 22:12, Pablo Galindo Salgado a écrit : > > Float infinity is replaced with 1e309. Again, maybe someone wants > to render this differently? It sounds like an arbitrary choice (which > "works" as expected). > > That is not true. float('inf') is rendered as float('inf´): > >

[Python-Dev] Re: Exposing Tools/parser/unparse.py in the stdlib?

2019-11-19 Thread Batuhan Taskaya
This is a really great idea, after pretty ast.dump it will be great addition for people who works with AST code transformations. I think with the new end_lineno and end_col_offset information output can be little bit close the original. I want to volunteer the work if there is an open

[Python-Dev] Re: Exposing Tools/parser/unparse.py in the stdlib?

2019-11-19 Thread Nathaniel Smith
On Mon, Nov 18, 2019 at 4:41 PM Pablo Galindo Salgado wrote: > > Hi, > > What do people feel about exposing Tools/parser/unparse.py in the standard > library? Here is my initial rationale: > > * The tool already needs to be maintained and updated as is tested as part of > the test suite. > * I

[Python-Dev] Re: Exposing Tools/parser/unparse.py in the stdlib?

2019-11-19 Thread Pablo Galindo Salgado
> (*) unparse loses all formatting and comments. The output is not really "pretty". If you want to put unparse in the stdlib, maybe we should design an API to be able to plug an external formatter to get "PEP 8"-like coding style or Black coding style for example. The ast does not have comment or

[Python-Dev] Re: Exposing Tools/parser/unparse.py in the stdlib?

2019-11-19 Thread Victor Stinner
Hi, Le mar. 19 nov. 2019 à 01:42, Pablo Galindo Salgado a écrit : > What do people feel about exposing Tools/parser/unparse.py in the standard > library? I like the idea. I compared Lib/os.py to the unparse output and now I have many questions :-) (*) unparse loses all formatting and

[Python-Dev] Re: Exposing Tools/parser/unparse.py in the stdlib?

2019-11-18 Thread Guido van Rossum
I don't think the PEG parser switch would change anything -- it produces the same AST as the old parser and ast.parse(). It looks a reasonable thing to move into the stdlib (maybe as ast.unparse()?), assuming it's complete. Tests and doc need to be written. On Tue, Nov 19, 2019 at 1:08 AM

[Python-Dev] Re: Exposing Tools/parser/unparse.py in the stdlib?

2019-11-18 Thread Mahmoud Hashemi
>From the first time I found it years ago, I've often wondered why it wasn't exposed. I presumed due to certain API shifts I wasn't paying close attention to, that maybe the ast module was buffering. But I've definitely wanted to import it in the past. If the API is as stable as you say, then I