Unary plus operator and __pos__

Carlos Ribeiro carribeiro at gmail.com
Mon Sep 27 00:50:43 EDT 2004


I was checking the Prolog recipe in the Cookbook:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/303057

It's a clever implementation that explores some aspects of Python that
I wasn't aware of. One of them is the unary plus operator, that calls
the __pos__ method. It's something that can be highly useful in my own
experiments with the use of classes as a tool for generic declarative
descriptions of objects -- UI forms, reports, webpages, etc.

Now I'm curious about the operator itself. Why is  the unary plus
operator associated with the __pos__ magic method? I' can't see a
relation here, and I could not find much info (although I haven't
really looked very hard :-)

Anyone knows why is it so?

-- 
Carlos Ribeiro
Consultoria em Projetos
blog: http://rascunhosrotos.blogspot.com
blog: http://pythonnotes.blogspot.com
mail: carribeiro at gmail.com
mail: carribeiro at yahoo.com



More information about the Python-list mailing list