FAQ
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?

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 9 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedMay 24, '12 at 2:14p
activeMay 25, '12 at 10:44p
posts9
users9
websitepython.org

People

Translate

site design / logo © 2022 Grokbase