double underscore attributes?
Dan Bishop
danb_83 at yahoo.com
Sat Dec 10 16:22:50 EST 2005
bobueland at yahoo.com wrote:
...
> Every time I use dir(some module) I get a lot of attributes with double
> underscore, for example __add__. Ok, I thought __add__ must be a method
> which I can apply like this
...
> I tried
> >>> help(5.__add__)
>
> but got
> SyntaxError: invalid syntax
That's because the parser thinks "5." is a float, rather than the
integer 5 with a dot after it. If you want to refer to an attribute of
an integer literal, you can use "(5).__add__" or "5 .__add__" (with a
space).
More information about the Python-list
mailing list