How to convert a ">" into a >

Tim Roberts timr at
Sun Jun 22 06:45:49 CEST 2008

dominique <MyDomDom at> wrote:

>On Jun 21, 1:37 pm, John Machin <sjmac... at> wrote:
>> Look at the operator module. In your above example:
>> return {
>>    '>':,
>>    '=': operator.eq,
>>    '<':,
>>    }[variable]
>Thanks a lot John

Yes, but you need to remember that what you are getting is not literally an
operator.  That is, if you store that return value in a variable called
"op", you can't say this:

    if x op y:

Instead, what you have is a function, so you'll have to write it:

    if op( x, y ):
Tim Roberts, timr at
Providenza & Boekelheide, Inc.

More information about the Python-list mailing list