Python for Visual Basic or C# programmers

Max rabkinDELETE at mweb.co.za
Thu Jun 1 15:58:38 EDT 2006


Metalone wrote:
<on imitatting VB's irritating space-or-minus>
> 
> This might be a little too tricky.
> [" %d", "%d][n < 0] % n  --> selects list[0] or list[1] based upon sign
> of number
> 

("%+d" % 123).replace("+", " ") is slightly longer but instantly 
comprehensible, although I for one think your boolean indexing trick is 
cool.

--Max



More information about the Python-list mailing list