Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 737339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:42:35+00:00 2026-05-14T07:42:35+00:00

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

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:42:36+00:00Added an answer on May 14, 2026 at 7:42 am

    Define your own function that takes two conditions and an operator and evaluates:

    def my_eval(condition1, lo, condition2)
        return {
          'and': condition1 and condition2,
          'or': condition1 or condition2
               }[lo]
    

    and then evaluate the lot:

    condition = conditions[0]
    for cond, op in zip(conditions[1:], operators):
        condition = my_eval(condition, op, cond)
    

    Feel free to preprocess condition1 and condition2 in my_eval, you probably don’t intend to truth test the strings 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The problem is that I need to construct the following SELECT statement: SELECT c.Animal/Dog,
I need to construct some rather simple SQL, I suppose, but as it's a
I am attempting to insert data into a local SQLITE database file from a
So i need some support with my Ruby assignment, I'm not from US so
I need to create a strategy pattern where a user selects four strategies from
I would need some basic vector mathematics constructs in an application. Dot product, cross
Is contract to interface as object is to class? What is the need to
I need to create simple reusable javascript object publishing several methods and parameterized constructor.
Why do we need an init() method in servlet? Can't we use the constructor
Please write a list of tasks that a copy constructor and assignment operator need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.