Open carbonium14 opened 2 months ago
Thank you for the report! Could you please try the following snippet?
>>> import ast, astor
>>> node = ast.parse('this_is_a_sentence_that_is_very_long=this_is_a_sentence_that_is_extremely_long')
>>> code = astor.to_source(node=node, pretty_source=lambda source: ''.join(source))
>>> print(code)
this_is_a_sentence_that_is_very_long = this_is_a_sentence_that_is_extremely_long
Thank you for the report! Could you please try the following snippet?
>>> import ast, astor >>> node = ast.parse('this_is_a_sentence_that_is_very_long=this_is_a_sentence_that_is_extremely_long') >>> code = astor.to_source(node=node, pretty_source=lambda source: ''.join(source)) >>> print(code) this_is_a_sentence_that_is_very_long = this_is_a_sentence_that_is_extremely_long
it works! thanks for your answer!
Awesome! I'd be happy to review a documentation PR that mentions how to disable PEP 8 styling.
When I used
astor.to_source
, I found that during the conversion process, when a line of code is very long, it will automatically wrap.What I hope to get is
this_is_a_sentence_that_is_very_long=this_is_a_sentence_that_is_extremely_long
, that is, no matter how long a line of code is, it will be gathered into one line.I found that thepretty_string
function can manually format the code, but I found that no matter how I set this function, I cannot achieve the expected output. How can I solve this problem?