Oct-17-2019, 04:21 AM
(This post was last modified: Oct-17-2019, 04:22 AM by steve_shambles.)
I too struggler with using classes and I too don't like to use global statements.
To get around this I use a very simple class (that even I can understand)
to hold all the variables and thus making the variables global without using
the global statement.
Note: This way will be very much frowned upon by Python developers, but
I find it a useful stop-gap until IU can properly get my head around classes.
Example:
Then I can use the variables like this:
Glo.max_images +=1
if Glo.grab_secs etc....
For a full explanation:
https://stevepython.wordpress.com/2019/0...-variables
To get around this I use a very simple class (that even I can understand)
to hold all the variables and thus making the variables global without using
the global statement.
Note: This way will be very much frowned upon by Python developers, but
I find it a useful stop-gap until IU can properly get my head around classes.
Example:
1 2 3 4 5 6 7 8 9 |
class Glo: '''global store, this makes these vars global,e.g Glo.var''' save_on = True stop_thread = False file_name = "" file_inc = 0 image_count = 0 grab_secs = 2 max_images = 7200 |
Glo.max_images +=1
if Glo.grab_secs etc....
For a full explanation:
https://stevepython.wordpress.com/2019/0...-variables