Stefan Behnel, 23.02.2014 19:51:
> Cython has typed
> assignments, so a straight forward idea would be to handle TypeErrors in
> assignments like this:
> 
>     cdef str s
>     s = x except TypeError: str(x)

Similar code in Python would be this:

    from array import array
    x = array('i', [1,2,3])
    value = "123"

    x[0] = value except TypeError: int(value)


> However, I guess that would similarly counter the idea of exception
> handling in an *expression*, and the correct and non-ambiguous way to do
> this would be to spell out the try-except block.

Stefan


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to