Constructing an if statement from the client data in python

Posted by Vishal on Stack Overflow See other posts from Stack Overflow or by Vishal
Published on 2010-04-13T14:48:50Z Indexed on 2010/04/13 14:53 UTC
Read the original article Hit count: 210

Filed under:

Hi,

I need to construct an if statement from the data coming from the client as below:

conditions: condition1, condition2, condition3, condition4 logical operators: lo1, lo2, lo3 (Possible values: "and" "or")

Eg.

if condition1 lo1 condition2 lo3 condition4:
    # Do something

I can think of eval/exec but not sure how safe they are! Any better approach or alternative? Appreciate your responses :)

PS: Client-side: Flex, Server-side: Python, over internet

Thanks

© Stack Overflow or respective owner

Related posts about python