Alex Light wrote:
i would suggest overloading the 'with', 'as' combo
c = sqrt(a*a + b*b) with: get_a(), get_b() as a, b
or
c = sqrt(a*a + b*b) with: get_a() as a get_b() as b
Why use 'as'? Why not: c = sqrt(a*a + b*b) with: a = get_a() b = get_b() which is like: def _(): a = get_a() b = get_b() return sqrt(a*a + b*b) c = _() del _
it reads well and plus it follows since this statement acts similarly to a regular with and as statement with the behavior of the context manager being (in psudocode): set up: store original value of variable if any and set variable to new value. tear down: set value back to original or delete from local namespace if it never had one
additionally we do not need to introduce any new keywords
any way that this is implemented though it would be quite useful
On Tue, Jul 20, 2010 at 2:35 PM, George Sakkis <george.sakkis@gmail.com <mailto:george.sakkis@gmail.com>> wrote:
On Tue, Jul 20, 2010 at 8:29 PM, Daniel Stutzbach <daniel@stutzbachenterprises.com <mailto:daniel@stutzbachenterprises.com>> wrote:
> On Tue, Jul 20, 2010 at 1:16 PM, Guido van Rossum <guido@python.org <mailto:guido@python.org>> wrote: >> >> Given the large number of Python users familiar with SQL compared to >> those familiar with Haskell, I think we'd do wise to pick a different >> keyword instead of 'where'. I can't think of one right now though. > > Taking a cue from mathematics, how about "given"? > > c = sqrt(a*a + b*b) given: > a = retrieve_a() > b = retrieve_b()
Or if we'd rather overload an existing keyword than add a new one, "with" reads well too.