Global Variables

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
Nikunj_Vadher
Posts: 11
Joined: Mon Dec 10, 2018 6:37 am

Global Variables

Post by Nikunj_Vadher » Tue Dec 18, 2018 9:27 am

How to declare global variables in micropython that can be accessible from boot.py, main.py and many files.
creating and writing and updating file data taking time and getting into error.I want to declare only 2 variables.
Also want to create and freeze(compile) code for python server that listen on port for request.

Thank You.

kevinkk525
Posts: 326
Joined: Sat Feb 03, 2018 7:02 pm

Re: Global Variables

Post by kevinkk525 » Tue Dec 18, 2018 9:30 am

That's not possible in python, only in lua.
If you want to have accessible globals you have to declare those in a module e.g. "config.py" and then import that module in every other file/module that wants to access these.

Post Reply