Favorite non-python language trick?
Robert Kern
rkern at ucsd.edu
Mon Jun 27 00:41:02 EDT 2005
Terry Hancock wrote:
> On Sunday 26 June 2005 06:11 am, Robert Kern wrote:
>
>>Terry Hancock wrote:
>>
>>>On Sunday 26 June 2005 05:39 am, Torsten Bronger wrote:
>>>
>>>>However, then you must forbid a=b=1 for assigning to two variables
>>>>at the same time.
>>
>>You need to differentiate
>> a = b = 1
>>from
>> a = b == 1
>
> Okay, I see what you mean. I can't ever recall having needed the
> second form, though.
I use it all the time with Numeric's rich comparisons.
mask = some_arr == 999
> Of course, you could still do assignment like this:
>
> a, b = (1,)*2
>
> But I guess that's not exactly elegant. ;-)
Ya think? :-)
--
Robert Kern
rkern at ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
More information about the Python-list
mailing list