[prev in list] [next in list] [prev in thread] [next in thread]
List: python-ideas
Subject: Re: [Python-ideas] Combining test and assignment
From: Eike Hein <sho () eikehein ! com>
Date: 2012-01-22 4:18:24
Message-ID: 4F1B8E10.9050609 () eikehein ! com
[Download RAW message or body]
On 1/22/2012 5:11 AM, Chris Rebert wrote:
> That doesn't actually work (unless you happen to be writing code in
> module-level scope, where globals are locals):
Right, brainfart - the locals() of test aren't the
locals of the callsite obviously :). And nonlocal
won't work due to the lack of an existing binding
in the outer scope.
Can anyone think of another way to do an assignment
and a truth test in the same expression with today's
tools?
> http://docs.python.org/library/functions.html#locals :
> "Note: The contents of this dictionary should not be modified; changes
> may not affect the values of local and free variables used by the
> interpreter."
Yep, I was actually confusing this with vars() in terms
of whether modifying its return value is considered
kosher. Thanks. Sadly that makes the above harder ...
> Cheers,
> Chris
--
Best regards,
Eike Hein
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
http://mail.python.org/mailman/listinfo/python-ideas
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic