define
Marcus Alanen
marcus at infa.abo.fi
Sat May 10 10:50:49 EDT 2003
On 10 May 2003 14:27:18 GMT, Bengt Richter <bokr at oz.net> wrote:
>Ok, let's do the whole deal ;-)
>
> b = self.b
> sign = self.sign
> a = self.a
> c = self.c
> y = (-b + sign*sqrt(b**2 - 4.0*a*c))/2.0*a
> self.y = y
>vs
> with self ~ sqrt:
> y = (-b + sign*sqrt(b**2 - 4.0*a*c))/2.0*a
(ok, I was just pointing it out. )
>>Perhaps the other way around, use ~ for the short-name variables:
>> with x: ~y = (-~b + ~sign*sqrt(~b**2 - 4.0*~a*~c))/2.0*~a
>I guess I don't understand what you mean by "other way around." ISTM
>you just reintroduced the line noise again. The point of '~' was to
I mean that ~ could be used the special variables, not for the code
which is unrelated to the "with" statement. It seems to me to be
counter-intuitive that if you use "with x", you have to explicitely
state the code which does _not_ have to do with the x variable
("with x ~ sqrt")
>fix a single exception or two to the implicit designation of 'every'
>symbol.
Hm, how about the operators? I.e, in with x ~ sqrt: .... - 4.0...,
shouldn't x.__sub__ be used, since you didn't say it explicitely? I
honestly don't know enough of how python works, or would work, in this
case. with x ~ sqrt,__sub__: ... ?
>
>>Then the common case is to just write the code, instead of escaping it with ~.
>>When you want to use the short-names, you explicitely say so.
>But the reason for using a 'with x ~ sqrt:' in the first place would be
>that that "common case" was not "common" at all in that context ;-)
Fine by me :) Personally I find the with x ~ sqrt to be very ugly and
_maybe_ errorprone, but that's just me.
Marcus
More information about the Python-list
mailing list