[Python-ideas] except expression

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Feb 16 00:37:05 CET 2014


Steven D'Aprano wrote:
> On Sat, Feb 15, 2014 at 11:20:13AM +1300, Greg Ewing wrote:

>>Also it might be useful to be able to say
>>
>>   things.remove(i) (except ValueError: pass)
>>
>>which would be equivalent to
>>
>>   things.remove(i) (except ValueError: None)
> 
> Certainly not! pass implies that *no return result is generated at all*, 
> which is not possible in Python.

Well, it is, kind of -- an implicit None is produced
when you don't specify a return value for a function;
this is a similar thing.

Would it help if it were *only* allow it in a context
where the value of the expression is going to be ignored?

-- 
Greg


More information about the Python-ideas mailing list