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

MicroPython • Re: Question on Variables

$
0
0
if you use: [ 0, 0, 0, 0 ], then you have to make sure you index the array correctly, which can be done with variables, such as " values[morninghour]" where morninghour = 0, but you might as well have used variables instead of an array. Otherwise, you have the cryptic "values[0]" which is cryptic and non descriptive. Also, you no matter how you index the array, you are still performing the index calculation. If you use constants, such as "values[2]", that calculation would be performed at compile time, which is nebulous with a scripting language.

On the other hand, using explicit variables, as you listed, avoids the above issues.

Statistics: Posted by NotHerbert — Sat Feb 03, 2024 6:49 pm



Viewing all articles
Browse latest Browse all 5022

Trending Articles