boot.py Vs main.py
import __main__ print(__main__.__file__) AttributeError: 'module' object has no attribute '__file__'
import sys this_function_name = sys._getframe( ).f_code.co_name AttributeError: 'module' object has no attribute '_getframe'
import sys print (sys.argv) IndexError: list index out of range
work. Surely there must be a way in pycoms flavour of micropython to do this?
I've got identical copies of my non terminating software in boot.py & main.py, the idea being that if boot.py fails then main.py should run in lieu. But I'd like to get a diagnostic message when this happens so that's why I need a way of telling if the code is running as boot.py or main.py
if you do normal stuff, both files shall run. First boot than main.
You can set a local variable, a method or so, to print out for logging or to use in an if statement.
Do you still hunt your syntax error bug? If yes, try to precompile your stuff. You may use too much memory too early, so that the on device compiler fails with strange messages. Frozen files will be better for testing. Even the *.mpy files need RAM and may fail when the memory is heavy fragmented on an early stage. But testing such issues with precompiled files is quite easy compared with the frozen workflow
If you mix 4mb an lower device, develop on a smaller device and test the newer one quite often.