I noticed that some builtins have paramenters prefixed with ‘__’.
For example repr with def repr(__obj) -> str as signature.
Is this only a naming convention for builtins or does it also have a functional purpose?
>Solution :
This has no effect on the runtime and is an old naming convention. Before Python had positional-only arguments, developers would mark arguments with double underscores to indicate that they should only be called by position, not by name. So, in the case of repr, the double underscore indicates that you should always write repr(whatever), never repr(__obj=whatever).
Nowadays, in modern Python, we would be more likely to write
def repr(obj, /): ...
But going back through and changing all standard library functions to do so isn’t a priority and would likely be considered a breaking change.