py5coding / py5generator

Meta-programming project that creates the py5 library code.
https://py5coding.org/
GNU General Public License v3.0
52 stars 13 forks source link

Improve `NameError` exception message when Imported mode users have a `py5.` somewhere in their code #323

Closed hx2A closed 1 year ago

hx2A commented 1 year ago

Updated error message to provide this instead:

$ run_sketch test.py 
py5 encountered an error in your code:

File "test.py", line 4, in draw
    2    def draw():
    3        background('blue')
--> 4        rect(random_int(py5.width), 20, 30, 40)

NameError: The name "py5" is not defined. Your Sketch is also running in Imported Mode. Remember that in imported mode you do not access py5's methods with the `py5.` module prefix.