Why does 1.__add__(2) not work out?

Viewed 805

Possible Duplicate:
accessing a python int literals methods

In Python, everything is an object.

But then again, why doesn't the following snippet work?

1.__add__(2)

However, this does work:

n = 1
n.__add__(2)

What is the difference between n and 1?

Isn't it a design failure that it doesn't work? For instance, it does work with string literals as well.

"one".__add__("two")

For comparison, it works well on other purely object oriented languages too.

Let's take a closer look at this compiling c# example:

Console.WriteLine(100.ToString());

Then again, what distinguishes Python from C# in the perspective of everything is an object?

2 Answers
Related