Evan Driscoll schrieb:
On Aug 25, 3:47 pm, Evan Driscoll eva...@gmail.com wrote:
So here is my simplified version that only works for globals:
So I think this works if (1) you only use changed_value in the same
module as it's defined in (otherwise it picks up the globals from the
module it's
On Aug 25, 1:07 pm, Evan Driscoll eva...@gmail.com wrote:
On Aug 25, 2:33 pm, Evan Driscoll eva...@gmail.com wrote:
I want to make a context manager that will temporarily change the
value of a variable within the scope of a 'with' that uses it. This is
inspired by a C++ RAII object I've
On Aug 26, 10:15 am, Carl Banks pavlovevide...@gmail.com wrote:
Well, it wouldn't be a can I rebind a variable using a with-
statement thread if someone didn't post a solution that they thought
worked, but didn't test it on local variables.
I'm not going to deny it was pretty stupid... though
(If you don't want to read the following, note that you can answer my
question by writing a swap function.)
I want to make a context manager that will temporarily change the
value of a variable within the scope of a 'with' that uses it. This is
inspired by a C++ RAII object I've used in a few
On 8/25/2009 12:33 PM Evan Driscoll said...
snip
So my question is: is what I want possible to do in Python?
Probably not with immutables (as in your example) -- maybe otherwise.
Emile
--
http://mail.python.org/mailman/listinfo/python-list
On Aug 25, 2:33 pm, Evan Driscoll eva...@gmail.com wrote:
I want to make a context manager that will temporarily change the
value of a variable within the scope of a 'with' that uses it. This is
inspired by a C++ RAII object I've used in a few projects. Ideally,
what I want is something like
On Aug 25, 3:07 pm, Evan Driscoll eva...@gmail.com wrote:
Okay, so I think I actually got this with some consultation with a
friend. Critiques?
This is wrong; it's not quite working right. It does with the example
I posted, but not in a more thorough test.
I'm still ignoring the you can't do
On Aug 25, 3:25 pm, Diez B. Roggisch de...@nospam.web.de wrote:
Modifying locals isn't really allowed - it might stop working with
certain implementations of python.
And to be honest - I don't really see a use-case for your whole
approache. Why don't you want to introduce a new name?
Wow,
Evan Driscoll schrieb:
(If you don't want to read the following, note that you can answer my
question by writing a swap function.)
I want to make a context manager that will temporarily change the
value of a variable within the scope of a 'with' that uses it. This is
inspired by a C++ RAII
Evan Driscoll schrieb:
On Aug 25, 2:33 pm, Evan Driscoll eva...@gmail.com wrote:
I want to make a context manager that will temporarily change the
value of a variable within the scope of a 'with' that uses it. This is
inspired by a C++ RAII object I've used in a few projects. Ideally,
what I
On Aug 25, 3:47 pm, Evan Driscoll eva...@gmail.com wrote:
So here is my simplified version that only works for globals:
So I think this works if (1) you only use changed_value in the same
module as it's defined in (otherwise it picks up the globals from the
module it's defined in, which is
11 matches
Mail list logo