On 24 January 2013 11:35, Chris Angelico <ros...@gmail.com> wrote:
>
> It's usually fine to have int() complain about any non-numerics in the
> string, but I must confess, I do sometimes yearn for atoi() semantics:
> atoi("123asd") == 123, and atoi("qqq") == 0. I've not seen a
> convenient Python function for doing that. Usually it involves
> manually getting the digits off the front. All I want is to suppress
> the error on finding a non-digit. Oh well.
>

I'm interested to know what the situations are where you want the
behaviour of atoi().

Personally, I consider the int() function too permissive because of
its behaviour in truncating non-integer numeric types. But then that's
because I'm always paranoid that the values of my precious numbers are
being changed without my knowledge. From my vantage point I really
can't see why the ambiguous behaviour of atoi() would actually be
desired by anyone (unless they were stuck using a language that made
string manipulation generally a bit awkward).


Oscar
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to