Python Forum
Incrementing variable counter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Incrementing variable counter
#2
There are at least 3 ways to do this:

First, you can use it as a global variable. Show your function code so we can see how you attempted this and point out what could improve it.

Second, you could keep the value as an explicit variable in your main code and pass it to each of the functions as an argument.

Third, you could create a class, turn the functions into methods, and keep the value as an attribute. If you haven't worked with object oriented code before, there might be more steps to this, but in the long run it's more maintainable.
Reply


Messages In This Thread
Incrementing variable counter - by Milfredo - Sep-01-2020, 06:57 PM
RE: Incrementing variable counter - by bowlofred - Sep-01-2020, 07:04 PM
RE: Incrementing variable counter - by Milfredo - Sep-01-2020, 09:02 PM
RE: Incrementing variable counter - by bowlofred - Sep-01-2020, 09:43 PM
RE: Incrementing variable counter - by Milfredo - Sep-02-2020, 12:54 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020