define
Bengt Richter
bokr at oz.net
Sat May 10 01:33:48 EDT 2003
On 9 May 2003 19:20:48 -0700, danb_83 at yahoo.com (Dan Bishop) wrote:
>bokr at oz.net (Bengt Richter) wrote in message news:<b9gobu$ndd$0 at 216.39.172.122>
>...
>> I can sympathize with a desire to avoid writing, e.g.,
>>
>> x.y = (-x.b + x.sign*sqrt(x.b**2 - 4.0*x.a*x.c))/2.0*x.a
>>
>> in favor of something like, e.g.,
>>
>> using y, b, sign, a, c with x:
>> y = (-b + sign*sqrt(b**2 - 4.0*a*c))/2.0*a
>
>But this requires you to type 12 extra characters. What's the advantage?
That the actual formula line reads without line noise ;-)
The self version sticks out even more. I.e., compare reading
self.y = (-self.b + self.sign*sqrt(self.b**2 - 4.0*self.a*self.c))/2.0*self.a
vs
y = (-b + sign*sqrt(b**2 - 4.0*a*c))/2.0*a
>
>> Or, perhaps, alternatively,
>>
>> with (y, b, sign, a, c) in x:
>> y = (-b + sign*sqrt(b**2 - 4.0*a*c))/2.0*a
>>
>> Or, when it applies to every symbol used (same-line suite optional, of course),
>>
>> with x: y = (-b + sign*sqrt(b**2 - 4.0*a*c))/2.0*a
>
>That wouldn't work: sqrt isn't an attribute of x.
Oops, "applies to every symbol" was wrong. Good catch. Maybe '~' to exclude a symbol (or more):
with x ~ sqrt: y = (-b + sign*sqrt(b**2 - 4.0*a*c))/2.0*a
>
>Or if it did work, how would you know which names belonged to x and which didn't?
with x ~ sqrt: # freshly invented to answer your question ;-)
>
>I don't like the idea at all.
Not even the look of the uncluttered formula part?
>
>> Perhaps it's time to reexamine whether it could be done nicely somehow?
Regards,
Bengt Richter
More information about the Python-list
mailing list