A C-like if statement

Dave Hansen iddw at hotmail.com
Thu Feb 23 14:43:46 EST 2006


On Thu, 23 Feb 2006 12:04:38 -0700 in comp.lang.python, "Bob Greschke"
<bob at passcal.nmt.edu> wrote:

>
>"Roy Smith" <roy at panix.com> wrote in message 
>news:dtl04p$5q2$1 at reader2.panix.com...
[...]

>> try:
>>    i = a.find("3")
>>    print "It's here: ", i
>> except NotFound:
>>    print "No 3's here"
>
>Nuts.  I guess you're right.  It wouldn't be proper.  Things are added or 
>proposed every day for Python that I can't even pronounce, but a simple 'if 
>(I = a.find("3")) != -1' isn't allowed.  Huh.  It might be time to go back 
>to BASIC. :)

I think you'll find that BASIC doesn't allow it either...

Of the "missing" "features" of Python, this one is waaaaaay down on my
list.  In fact, it's not there at all.  What I _really_ miss is
do{...}while.  The best workaround I've found is unaesthetic, IMHO:

   while 1:
      # stuff
      if exit_condition: break

Regards,
                                        -=Dave

-- 
Change is inevitable, progress is not.



More information about the Python-list mailing list