Overloading the "and" operator
Terry Reedy
tjreedy at udel.edu
Sun Mar 13 15:37:20 EST 2005
More information about the Python-list mailing list
Sun Mar 13 15:37:20 EST 2005
- Previous message (by thread): Overloading the "and" operator
- Next message (by thread): psycopg authentication
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Fredrik Bertilsson" <fredrik_bertilsson at passagen.se> wrote in message news:31f7e57d.0503122133.b9073e1 at posting.google.com... >I am trying to overload the "and" operatior, but my __and__ method is > never called. That is because, properly speaking, 'and' and 'or' are, in Python, in-line flow-control keywords (related to 'if' and 'else'), and not operators. Operators are abbreviated function calls. For binary operators, this means evaluating both left and right operands and then calling the function, which may hook into a special method, as you tried to do. 'And' and 'or', on the other hand, try to avoid evaluating the right expression. Terry J. Reedy
- Previous message (by thread): Overloading the "and" operator
- Next message (by thread): psycopg authentication
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list