![]() |
Reset a variable - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Reset a variable (/thread-20561.html) |
Reset a variable - mln4python - Aug-19-2019 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 RE: Reset a variable - buran - Aug-19-2019 what about just value = -999 ? That is assuming your variable is value
RE: Reset a variable - mln4python - Aug-19-2019 (Aug-19-2019, 07:34 AM)buran Wrote: what about just 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 RE: Reset a variable - buran - Aug-19-2019 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 RE: Reset a variable - mln4python - Aug-19-2019 (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 ! |