question on log as an instance method

Franck Ditter franck at ditter.org
Sun Oct 7 04:33:36 EDT 2012


Hi ! Here is Python 3.2.3, MacOSX-Lion

Question : I may consider + as an hidden instance method , as
1+2 is equivalent to (1).__add__(2) ?
I also consider __abs__ as an instance method :
>>> (-2).__abs__()
2

Question 1 : could the parser cope with the mandatory space
in 1 .__add__(2) ?

Question 2 : After importing math, why can't I consider log as
an instance method, after all ?
>>> (4).__log__()
AttributeError: 'float' object has no attribute '__log__'

Thanks for your answers.

   franck



More information about the Python-list mailing list