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 7583247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:37:57+00:00 2026-05-30T18:37:57+00:00

I just recently had a chance to take a look at web2py framework and

  • 0

I just recently had a chance to take a look at web2py framework and although I have some prior experience with Django and more so with plain Python, I couldn’t make sense out of the Query system that web2py employs.

Let’s take this example from web2py book

db = DAL('sqlite://storage.db')
myquery = (db.mytable.myfield > 'A')
myset = db(myquery)
rows = myset.select()
for row in rows:
    print row.myfield

In a SO comment web2py author says that (db.mytable.myfield > 'A') does not evaluate to True/False directly and it’s actually evaluated for each row at the time of selection. I understand this is what allows these expressions to be used as query objects and even be combined.

I’ve tried to find an answer to this online but couldn’t, so here is my question: How is those query expressions are not evaluating to True/False right away? Why is value of myquery is not, say, True? What Python feature that I’m probably missing allows this to work?

  • 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-30T18:37:58+00:00Added an answer on May 30, 2026 at 6:37 pm

    The other answers have it, but just to provide a little more web2py-specific detail:

    db.mytable.myfield > 'A'
    

    db.mytable.myfield is an instance of the web2py DAL Field class, which inherits from the DAL Expression class. The Expression class itself overloads a number of Python operators, such as ==, <, >, etc. These overloaded operators, when applied to Expression (and therefore Field) objects return an instance of the DAL Query class rather than a standard Python boolean object. Here is the source code for the > (__gt__) operator.

    See here for more on operator overloading in Python.

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

Sidebar

Related Questions

Have had to write my first proper multithreaded coded recently, and realised just how
I had not used the tag element of views until just recently, and have
I have an Atom feed for my blog . I recently had some audio
Either I had a bad dream recently or I am just too stupid to
I just recently started diving into Real World Haskell and the book provides some
We have recently migrated some 30 DTS packages in SQL Server 2000 to SSIS
We've just recently switched to VS 2010 and i had a solution that was
I recently had to build an app which was pretty big (just under 180mb)
Summary I recently had a conversation with the creator of a framework that one
I had created a MDF database file and I just recently reformatted my computer.

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.