math functions with non numeric args

Irmen de Jong irmen.NOSPAM at xs4all.nl
Sun Jun 30 14:57:10 EDT 2013


On 30-6-2013 20:46, Andrew Z wrote:
> Hello,
> 
> print max(-10, 10)
> 10
> print max('-10', 10)
> -10
> 
> My guess max converts string to number bye decoding each of the characters to it's ASCII
> equivalent?
> 
> Where can i read more on exactly how the situations like these are dealt with?
> 
> Thank you
> AZ
> 

Use Python 3.x instead.

>>> max('-10',10)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unorderable types: int() > str()
>>>


Irmen




More information about the Python-list mailing list