On Jun 22, 6:45 am, Tim Roberts <[EMAIL PROTECTED]> wrote:
> dominique <[EMAIL PROTECTED]> wrote:
> >On Jun 21, 1:37 pm, John Machin <[EMAIL PROTECTED]> wrote:
>
> >> Look at the operator module. In your above example:
>
> >> return {
> >>    '>': operator.gt,
> >>    '=': operator.eq,
> >>    '<': operator.lt,
> >>    }[variable]
>
> >Thanks a lot John
> >Dominique
>
> 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, [EMAIL PROTECTED]
> Providenza & Boekelheide, Inc.

Thanks for the tip.
Dominique
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to