Tim Chase wrote:
> Is there some set of preexisting functions that do this sort
> of "sensible" conversions without griping about crazy values
> passed to them?

No, because this isn't Perl.

Seriously, it's a core principle of the Python language not to presume
what a user considers to be "sensible", because, frankly, what's
sensible isn't going to be the same for everyone.  If you type "input
this" at a Python prompt, you'll see a list of guidelines the language
designers use.  The one in effect here is: In the face of ambiguity,
refuse the temptation to guess.

Out of curiosity, what would Perl do?

$ perl -e 'print int("3.14")'; echo
3
$ perl -e 'print int("33fwegfgqer")'; echo
33
$ perl -e 'print int("3OO3")'; echo
3
$ perl -e 'print int({"a","b","c","d"})'; echo
135601192
$ perl -e 'print int("hello, world")'; echo
0

Somebody (I'm guessing Larry Wall himself) thought it was "sensible"
for int() to return the internal pointer of the hash.


Carl Banks

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

Reply via email to