[Python-ideas] Statements vs Expressions... why?

Arnaud Delobelle arnodel at googlemail.com
Sun Sep 14 08:23:07 CEST 2008

On 13 Sep 2008, at 23:17, Cliff Wells wrote:

> On Sat, 2008-09-13 at 19:01 +0100, Arnaud Delobelle wrote:
>> So what does:
>> a = (if False: 1)
>> evaluate to?
> That's a good question.  This is one of those areas where a definition
> would need to be created.  My inclination is to say None (much like a
> function with no return statement).

Assuming the return value of "None", I go back to an example I gave  

    factors = for x in range(2, n):
        if n % x == 0:

This doesn't work as intended (filtering out the non-factors).  How to  
make it work?  The only way I can think of is to make (if 0: 1) return  
a special "non-value" which loops will then filter out.  But then we  
all know what happens to non-values.

So how would you solve this problem?

> Cliff


More information about the Python-ideas mailing list