In Python, can I use the value of a global variable in a method at the time of it's definition, but not change when that variable is changed?
It's difficult to describe the behavior that I need, so I'll give an example. When running the following code,
, but I would like a way to make
, which is the value of
at the time of
x = "spam"
x = "eggs"
This doesn't seem very pythonic, but I've given a lot of thought to the problem I'm facing, and have concluded that this solution is the most elegant. I can give more details about the exact example that requires this solution if that's necessary.