I have written a function in micropython that attempts to retrieve uname information and strip out stuff I don't want and then return a value:
import os
def get_uname():
my_uname = os.uname()[3]
my_uname = my_uname.replace("(GNU 9.3.0 MinSizeRel)", "")
my_uname = my_uname.replace(" on ", "-")
my_uname = my_uname.replace(" ", "")
return my_uname
Every time I try to import it as a module I get an error message:
import sw-ver
Traceback (most recent call last):
File "<stdin>", line 1
SyntaxError: invalid syntax
However if I copy and paste the function directly into repl, it is successful, no errors:
>>> import os
>>> def get_uname():
... my_uname = os.uname()[3]
... my_uname = my_uname.replace("(GNU 9.3.0 MinSizeRel)", "")
... my_uname = my_uname.replace(" on ", "-")
... my_uname = my_uname.replace(" ", "")
... return my_uname
...
...
...
>>> get_uname()
'v1.14-2021-02-05'
>>>
I have tried it every way i can think of, I renamed the file just in case that was causing the problem. Does anyone have a suggestion on how to troubleshoot this?
thanks!