Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8015

MicroPython • Global confusion

$
0
0
Ok I'm confused (again!)

I have a main module (KQC.py which will become main.py) in which I wish to define a global constant (UNITS_PER_MM) which ideally needs to be available to other modules (classes) . I'd like to keep this in the main module if possible so it is obvious to anyone modifying the code what it is (rather than a globals.py module)

so far I've tried : (forgive the lack of /code/ enclosure but i think it'll add even more confusion)

UNITS_PER_MM = const(10000) - which appears to work within the main module but nowhere else

global UNITS_PER_MM - within the functions , with and without defining const()

I know i could probably from KQC import UNITS_PER_MM but KQC.py will eventually become main.py

So, what am i missing guys?

Bill

Statistics: Posted by BillTodd — Thu Dec 18, 2025 3:58 pm



Viewing all articles
Browse latest Browse all 8015

Trending Articles