Newbie question about formatting long conditionals

Grant Edwards grante at visi.com
Wed Jul 28 17:59:17 EDT 2004


>     	... if the "if" condition gets too long and unweildy for a single 
> line, is there any way to format it along these lines?:
>
> #############
> a = 1
> b = 2
> c = 3
> d = 4
>
> if a == 1 
>   and b < 4 
>   and (c == 2 or d == 4):
>     print "Conditions met!"
> #############

if a == 1 \
  and b < 4 \
  and (c == 2 or d == 4):
    print "Conditions met!"
            

if (a == 1
     and b < 4
     and (c == 2 or d == 4)):
    print "Conditions met!"
    
            



-- 
Grant Edwards                   grante             Yow!  One FISHWICH coming
                                  at               up!!
                               visi.com            



More information about the Python-list mailing list