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

  • SEARCH
  • Home
  • 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 8047255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:02:42+00:00 2026-06-05T06:02:42+00:00

Folks, we have the following problem: we’ve got several objects containing table data that

  • 0

Folks, we have the following problem: we’ve got several objects containing table data that look something like this:

{'field1':'value1','field2':'value2', ...}

At some point during runtime we need to “select” data from these objects (tables) in the same way one were to query a DB (i.e. get records in this set that matches field1 == some_value and field2==some_other_value). We don’t have access to the original RDBMS or db views. We fiddled with the idea of using an intermediary DB (like sqlite) and then query it for the data as needed.

But it felt “smelly” to add another moving part to the app just for dataset querying purposes. So, my question is: is there a pythonic way to approach this? Should we bite the bullet and push the data to a DB, query the DB, then delete? Thanks in advance for your opinion and input.

The data is a list of dictionaries.

  • 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-06-05T06:02:44+00:00Added an answer on June 5, 2026 at 6:02 am
    def one_of(alternatives):
        return lambda val: val in alternatives
    
    def within(frm, to):
        return lambda val: frm <= val <= to
    
    def gte(const):
        return lambda val: val >= const
    
    def lte(const):
        return lambda val: val <= const
    
    def exact(const):
        return lambda val: val == const
    
    
    def select(data, **kwargs):
        for item in data:
            if all(chk(item[key]) for key, chk in kwargs.items()):
                yield item
    
    data = [
        {'id': 1, 'name': 'Ann', 'age': 25},
        {'id': 2, 'name': 'Tom', 'age': 10},
        {'id': 3, 'name': 'John', 'age': 40},
        {'id': 4, 'name': 'Tom', 'age': 18},
    ]
    
    for person in select(data, age=gte(15), id=within(3, 4), name=exact('Tom')):
        print person['name']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Folks, i have the following problem. My website uses an iframe to select an
I have xml that essentialy looks like the following (my actual .xml is a
I have seen several places in stackoverflow where folks have elegantly and easily turned
Folks, I have a problem. I am a writing a script in python which
So, folks. Got an interesting occurrence going on here. I have a windows forms
Hej folks, I'm currently completely stuck with the following and don't even have the
I have a PartialViewModel in my MVC application that contains the following set up:
I have the following scenario: 1) A phone book table 2) Multiple ways of
Hello folks :) I have a quick question - For the following NSMutableArray: NSMutableArray
Hi folks I have the following error on line 11 in this controller code

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.