0

I am trying to use eval to load. It does not work as in just running it. See Python shell:
The version is: python3.6m

>>>> eval( 'import re' )
Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "<string>", line 1
    import re
         ^
    SyntaxError: invalid syntax
    >>> import re
>>>
user1134991
  • 3,003
  • 2
  • 25
  • 35
  • 3
    [`eval`](https://docs.python.org/3/library/functions.html#eval) evaluates expressions. `import re` is not an expression. You could use [`exec`](https://docs.python.org/3/library/functions.html#exec) if you have some reason for actually wanting to do this. – khelwood Mar 31 '21 at 15:09
  • https://stackoverflow.com/questions/4728073/what-is-the-difference-between-an-expression-and-a-statement-in-python – rdas Mar 31 '21 at 15:11

0 Answers0