How is the __format__ method supposed to be used for int?

int, python

Solution

It's used for Py3k's new string formatting scheme.

You can find more info here:

http://docs.python.org/whatsnew/2.6.html#pep-3101-advanced-string-formatting

You are right that it isn't called directly. It's called by `str.format` or the new `format` builtin.

Problem

I saw there was a `__format__` method but help(`int.__format__`) doesn't provide any help. I also know you're not suppose to call a `__method__` directly. When is this method called? Which is its argument?

Original source