I am reading Practical Programming - An Introduction to Computer Science Using Python 3. They give this example:

>>> abs(-3)
3

>>> -3 .__abs__()
3

When I try it in idle or a terminal I get different results.

Python 3.3.5 (default, Mar 12 2014, 02:09:17)
[GCC 4.6.3] on linux

>>> abs(-3)
3

>>> -3 .__abs__()
-3

If I use a variable it works.

>>> x = -3
>>> x.__abs__()
3

I am curious as to what is happening. Is the book wrong? I checked it's errata and nothing is mentioned.

Regards, Jim



_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to