Skip to content

Attribute Error on for-in loop #1

@emablekos

Description

@emablekos

Thanks for this code.

I get an attribute error when doing a for-in loop.

def foo():
    a = ["a", "b"]
    b = "c"
    for val in a:
        b = val

causes:

<_ast.For object at 0x1042ebb90> <class '_ast.For'> <_ast.Name object at 0x1042ebdd0> <class '_ast.Name'>
Traceback (most recent call last):
  File "py2tex.py", line 235, in <module>
    main()
  File "py2tex.py", line 229, in main
    py2tex.visit(ast.parse(source))
  File "py2tex.py", line 33, in visit
    result = super().visit(node)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "py2tex.py", line 44, in visit_Module
    self.visit(stmt)
  File "py2tex.py", line 33, in visit
    result = super().visit(node)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "py2tex.py", line 71, in visit_FunctionDef
    self.body(node.body)
  File "py2tex.py", line 48, in body
    self.visit_all(body)
  File "py2tex.py", line 40, in visit_all
    self.visit(node)
  File "py2tex.py", line 33, in visit
    result = super().visit(node)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "py2tex.py", line 145, in visit_For
    nargs = len(node.iter.args)
AttributeError: 'Name' object has no attribute 'args'

I am able to generate latex from other python code and render it to pdf.

On Python 3.7.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions