Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reset a variable
#1
Hi all,

Is there any way to reset a variable value without using classes ?

For example, I initialize a variable to -999 and then do some calculations. In the middle of the program, I want to reset its value back to -999 (initialized value). Is this possible, preferably without using classes ?

Thanks in advance !

-MLN
Reply
#2
what about just value = -999? That is assuming your variable is value
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(Aug-19-2019, 07:34 AM)buran Wrote: what about just value = -999? That is assuming your variable is value

Hi buran,

Thanks for the reply. Little more details on what I want to do...

value = -999
... # some other code
a = b + c
... # some other calculations
value = a + (x * y)
... # some other calculations
value.reset() # this should set value = -999 again
# OR
reset(value) # this should set value = -999 again
Reply
#4
value = -999
... # some other code
a = b + c
... # some other calculations
value = a + (x * y)
... # some other calculations
value = -999 # this set value = -999 again
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
(Aug-19-2019, 07:44 AM)buran Wrote:
value = -999
... # some other code
a = b + c
... # some other calculations
value = a + (x * y)
... # some other calculations
value = -999 # this set value = -999 again

Thanks buran !

In fact, I need to generate python code like above, using my python script (basically converting other language code into python). I think better I use dictionaries to store these values and assign the respective values when I need to generate code for "reset". Thanks for your help again !
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Reset Variable problem IcodeUser8 3 2,312 Jul-20-2020, 12:20 PM
Last Post: IcodeUser8

Forum Jump:

User Panel Messages

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