Dynamic comparison operators

Phil Le Bienheureux phil.le.bienheureux at gmail.com
Thu May 24 10:32:11 EDT 2012


Hello,

You can pass an operator as an argument to your function.

See :
http://docs.python.org/library/operator.html

Regards,


---------- Forwarded message ----------
From: <mlangenhoven at gmail.com>
Date: 2012/5/24
Subject: Dynamic comparison operators
To: python-list at python.org


I would like to pass something like this into a function
test(val1,val2,'>=')

and it should come back with True or False.

Is there a way to dynamically compare 2 values like this or will I have to
code each operator individually?
--
http://mail.python.org/mailman/listinfo/python-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120524/8cf18be0/attachment.html>


More information about the Python-list mailing list