[PATCH 0/4] Speed improvement in fetch/clone

Jan Hudec bulb at ucw.cz
Thu Jan 19 12:29:39 GMT 2006


On Thu, Jan 19, 2006 at 01:56:32 -0800, Robey Pointer wrote:
> 
> On 18 Jan 2006, at 13:52, Goffredo Baroncelli wrote:
> 
> >+        pb = pb and pb or bzrlib.ui.ui_factory.progress_bar()
> 
> I wanna give a -1 to this line.  This construction (x and y or z) and  
> its pitfalls is actually the reason the ternary operator was added to  
> python 2.5 and even after long discussions about what it means, I  
> *still* find it confusing.
> 
> A 4-line if/else will cost you screen real estate but win you the  
> love of your fellow man. :)

Besides it will only be a 2-line if. The expression is screwed, but IMHO
not for using and+or for ternary (I am used to that from other
languages (that do have ternary, by the way)), but for:
1) Assigning what is already assigned.
2) Containing redundant terms -- (pb and pb) == pb

In languages that have it I'd suggest pb or= ....progress_bar(), but
python only supportst augmented assignment for arithmetic operators.

-- 
						 Jan 'Bulb' Hudec <bulb at ucw.cz>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060119/ae17909f/attachment.pgp 


More information about the bazaar mailing list