Why is "while" ticking me off???

Aahz Maruch aahz at panix.com
Mon Oct 9 19:53:51 EDT 2000


In article <87aecdmyo3.fsf at cartman.azz.net>,
Adam Sampson  <ats1 at ukc.ac.uk> wrote:
>aahz at panix.com (Aahz Maruch) writes:
>> In article <87zokes2wc.fsf at cartman.azz.net>,
>> Adam Sampson  <ats1 at ukc.ac.uk> wrote:
>>>
>>>How about adding a "set to" operator?
>>>
>>>if a := dict[k1]:
>>>	a.something()
>> 
>> See dict.setdefault() in the Python 2.0 documentation.
>
>I wasn't being serious, but dict.setdefault() is backwards from what I
>was intending there. If = were an operator in Python with the same
>meaning it has in C, then you could have written that as:
>
>if a = dict[k1]:
>	a.something()

OIC.  Well, in Python, I'd write this as

if dict[k1]:
  dict[k1].something()

assuming I were certain that k1 existed in dict, which you'd have to do
in C (null pointer bugs are so much fun).
-- 
                      --- Aahz (Copyright 2000 by aahz at pobox.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

"[I have a] windmill fetish."  --Darkhawk



More information about the Python-list mailing list