Skip to content
Discussion options

You must be logged in to vote

I don’t know if that helps in your case, but you can distinguish whether main.py is being run from MicroPython startup or from import main by checking __name__, as commonly done in CPython:

if __name__ == '__main__':
    # called from startup
else:
    # __name__ == 'main'
    # called from import

(Example)

Replies: 5 comments 8 replies

Comment options

You must be logged in to vote
4 replies
@FoxFreejack
Comment options

@jimmo
Comment options

jimmo Sep 8, 2022
Maintainer

@FoxFreejack
Comment options

@jimmo
Comment options

jimmo Sep 8, 2022
Maintainer

Comment options

You must be logged in to vote
0 replies
Answer selected by Josverl
Comment options

You must be logged in to vote
1 reply
@jmparatte
Comment options

Comment options

You must be logged in to vote
1 reply
@davidhuwmorgan
Comment options

Comment options

You must be logged in to vote
2 replies
@PCal53
Comment options

@PCal53
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
8 participants