[Tutor] __abs__() not acting as expected
Ben Finney
ben+python at benfinney.id.au
Mon Mar 24 07:06:09 CET 2014
Dave Angel <davea at davea.name> writes:
> Ben is right, dunder methods don't belong in introductory texts.
[…]
> But he didn't show you the simplest fix:
>
> (-3).__abs__()
I disagree; the simplest fix is not to call that method directly, and
just use::
abs(-3)
--
\ “Computer perspective on Moore's Law: Human effort becomes |
`\ twice as expensive roughly every two years.” —anonymous |
_o__) |
Ben Finney
More information about the Tutor
mailing list