PEP 308: some candidate uses cases from live code

James J. Besemer jb at cascade-sys.com
Mon Feb 10 21:32:30 EST 2003


Steve Holden wrote:


> However, it clearly introduces new precedence problems into the syntax: 

Not a problem.  You simply evidently didn't fully understand the proposal as 
Andrew specified it in the grammar.

> how do I know you meant
> 
>	(run, (if run==1: "" else: "s"), timeTaken)
> 
> 
> and not (apart from the run-time error it would produce)
> 
>	(run, if run==1: "" else: ("s", timeTaken))
> 

The former would apply and you know this because the new if constuct binds at 
a similar level as the "or" operator. Actually, relative to ",", if/else is 
similar to "+", so it's the same rationale for which

		( run, test + "s", timeTaken )

would never mean

		( run, test + ("s", timeTaken ))

Actually, "," is comparatively so low priority, so they break up just about 
anything expression-based.

When you think about it, this all is fairly intuitive.

--jb

-- 
James J. Besemer		503-280-0838 voice
2727 NE Skidmore St.		503-280-0375 fax
Portland, Oregon 97211-6557	mailto:jb at cascade-sys.com
				http://cascade-sys.com	







More information about the Python-list mailing list