[Tutor] if...elif question

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Wed, 3 Oct 2001 23:36:32 -0700 (PDT)


On Wed, 3 Oct 2001 alan.gauld@bt.com wrote:

> >     elif 60 <= percent < 70:
> > 
> > "If the percent is between the range of 60 and 70...".  Another way to
> > write this is:
> > 
> >     elif percent >= 60 and percent < 70:
> > 
> 
> Wow! Just when I think I'm getting to know Python something new bites me.
> I never knew Python could do comparisons like that - in fact I don't 
> think I know of any other programming language I've used that did it... 
> OTOH that may be because I always parenthesize comparisons from years 
> of being bitten by C...

Things will get very interesting when Python 2.2 comes out of beta...

    http://www.amk.ca/python/2.2/


Especially the fact that we'll soon be able to do this:

###
print 'look ma, no readlines'
for line in open('hello.txt'): print line
###

and do other fun stuff that we previously said was bad syntax... *grin*