Double underscore names
Christian Heimes
lists at cheimes.de
Tue Feb 12 17:58:30 EST 2008
Steven D'Aprano wrote:
> So what do folks think? I believe the protocol idiom ("look for a method
> called __parrot__ and then do something with it") is too useful and
> powerful to be ignored, but then if __parrot__ is reserved by Python,
> what to do?
The Python core claims all rights for __magic__ methods with a leading
and trailing double underscore. Of course Python won't stop you from
introducing your own magic names but you are on your own.
Future versions of Python may introduce a magic hook with the same name.
Be warned and don't complain ;)
Christian
More information about the Python-list
mailing list