Page 1 of 1
Can I read enviromenz variables?
Posted: Mon Sep 05, 2022 1:40 pm
by uraich
Hi,
I would need to figure out the user's home directory on the unix port. So... I could try to find out what $HOME corresponds to. Can this be done in micropython?
Re: Can I read enviromenz variables?
Posted: Mon Sep 05, 2022 3:06 pm
by TheSilverBullet
import os
os.getenv('HOME')
Re: Can I read enviromenz variables?
Posted: Mon Sep 05, 2022 11:38 pm
by bulletmark
uraich wrote: ↑Mon Sep 05, 2022 1:40 pm
Hi,
I would need to figure out the user's home directory on the unix port. So... I could try to find out what $HOME corresponds to. Can this be done in micropython?
Think about how you would do this in ordinary Python and always try that first. I.e. exactly as posted above.
Re: Can I read enviromenz variables?
Posted: Tue Sep 06, 2022 10:23 am
by uraich
@TheSilverBullet: Thanks, this works! I could have seen it myself with help(os)