Replies: 2 comments 2 replies
-
|
In Python, a module runs when you import it, so could be what you're seeing. Pybricks works the same. I'm not sure what the other modules look like, but you could do something like this:
def say_hi():
print("Hi there!")And then in your main program: # Import the function, but don't run it yet
from hello_world import say_hi
# Run the function whenever you want
for i in range(4):
say_hi() |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Sorry, @laurensvalk, if
Then what is stopping say_hi from running immediately in your example?
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've had success calling classes from other files using
import __ from __and using the stop button example to change the hub light but I can't seem to get the stop button to call another class. Is it possible?When I run the program above, one of the classes runs instantly instead of waiting for a button press or timeout.
Beta Was this translation helpful? Give feedback.
All reactions