Remove masked elements from an array

holger krekel pyth at devel.trillke.net
Mon Apr 29 21:02:19 EDT 2002


This gets funny.

>> The first version uses filter.
>> 'filter' calls 'f' for every item in 'nums' and puts
>> the result into the new list iff it has a 'true' value.
>>
>> The second version uses list comprehension.
>> It basically does the same if you look closely
>> at it.
>
>*Don't* try this if zero is a valid value for your histogram:
>
>newnums = filter(None, nums)

This is a quite stretching forward declaration for 'this'.
"Don't try this" right after citing a sentence is rather
misguiding. Less ambivalent alternatives:

"Yes, but don't try this:"

"But don't try the following (if zero is ...)"

"Be careful with ..."

> [this is the line that you mentally and physically snipped]

No. Interpreted in a different and - dare i say - quite possible way. 
Unless you say that - by applying python's grammar - the ":" makes
it unambigous :-)

amazed-about-the-wonders-of-communication-ly yours Holger





More information about the Python-list mailing list