Is there a better way of doing this?

Steven D'Aprano steve at REMOVETHIScyber.com.au
Thu Jun 2 11:52:18 EDT 2005


On Mon, 30 May 2005 14:05:36 +0200, Magnus Lycka wrote:

> Steven D'Aprano wrote:
>  > print is a statement, not a function. The brackets are syntactically
>  > correct, but pointless. Remove them.
> ...
>> On Sat, 28 May 2005 13:24:19 +0000, Michael wrote:
>>> while( newNS ):
>> 
>> Guido (our Benevolent Dictator For Life and creator of Python) hates
>> seeing whitespace next to parentheses. I agree with him. while(newNS)
>> good, while( newNS ) bad.
> 
> while is a statement, not a function. The brackets are syntactically
> correct, but pointless. Remove them. ;^)

Um. Er.

Of course I knew that. I deliberately made that error to see if others
were paying attention. Well done, go to the head of the class. *cough*

:-)


>      while newNS:
> 
> Not only are they pointless (in both print and while), but they are
> blurring the distinction between statements and callables, and they
> add noise. Only wrap the expression following a statement such as
> while, if, print etc in () if the following expression spans several
> lines.

Yes, of course you are right. Serves me right for replying to Usenet posts
in the wee hours of the morning. 

Although, pardon me for stating the obvious, using brackets for
precedence, or to add clarity by careful grouping, is always allowed even
if the expression doesn't span more than one line.

eg while (index > 0) and (not found or still_working):


-- 
Steven.





More information about the Python-list mailing list