Skip to content

py5 rejects valid static mode code #490

Closed
@hx2A

Description

@hx2A

from py5coding/py5book#122

This code:

size(200, 200)

def draw_random_circle():
    x = random_int(width)
    y = random_int(height)
    circle(x, y, random_int(25))
    
for _ in range(20):
    draw_random_circle()

Doesn't work in py5bot or with run_sketch. The draw_random_circle() function messes up the code evaluation because it matches the regex ^def draw[^:]*:.

Somehow I remember changing this code because of a bug @villares reported, where def draw () , which is valid Python, was getting skipped over when it should not.

So this bug has been in py5 for a while and we did not notice it until now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions