Skip to content

Instantly share code, notes, and snippets.

@ibizaman
Created April 9, 2014 14:00
Show Gist options
  • Save ibizaman/10273933 to your computer and use it in GitHub Desktop.
Save ibizaman/10273933 to your computer and use it in GitHub Desktop.
>>> r = RedBaron("c = 2 = 1")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/users/ppx/python/redbaron-master/redbaron.py", line 491, in __init__
self.data = [to_node(x, parent=self, on_attribute="root") for x in baron.parse(source_code)]
File "/users/ppx/python/baron-master/baron/baron.py", line 41, in parse
print_function_finder.visit(python_ast_parse(source_code))
File "/celestite/projects/cso-cpcc/Python/lib/python3.3/ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 1
SyntaxError: can't assign to literal
>>> r = RedBaron("c = 1")
>>> r[0].target = "c = 2"
>>> r.dumps()
'c = 2 = 1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment