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

MicroPython • Re: Question on Variables

$
0
0
It often depend on whether you need to access the variables programmatically
e.g. in a generic menu routine - it is sometime easier to be able to refer to the variable by number :-

Code:

  timelist[ menu_number]
if there's any chance the list could get shuffled by accident , then perhaps a dictionary might be a better option :-

Code:

timedict = {"morningstart": 0, "morningend":0, "eveningstart":0, "eveningend":0}
And, there always the option of wrapping the lot into a class and have all the control ever need :-)

Statistics: Posted by BillTodd — Tue Jan 23, 2024 9:21 pm



Viewing all articles
Browse latest Browse all 5031

Trending Articles