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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:23:58+00:00 2026-06-15T09:23:58+00:00

Why is neither of the following examples working? class Person(ndb.Model): first_name = ndb.StringProperty() last_name

  • 0

Why is neither of the following examples working?

class Person(ndb.Model):
   first_name = ndb.StringProperty()
   last_name = ndb.StringProperty()
   city = ndb.StringProperty()
   birth_year = ndb.IntegerProperty()
   height = ndb.IntegerProperty()

  @classmethod
  def get_person(self, _last_name, _max_height):
     a_person = Person.query(
           ndb.AND(
              Person.last_name == _last_name,
              Person. height == _max_height
       ))
      return a_person

The other example replaces Person with self:

@classmethod
  def get_person(self, _last_name, _max_height):
     a_person = self.query(
           ndb.AND(
              self.last_name == _last_name,
              self. height == _max_height
       ))
      return a_person

So basically I want to be able to call the get_person method with last_name and max_height and have it return a person (assume there is only one match). How do I accomplish that?

The calling class/object has the following lines:

my_person = Person.get_person('Doe',7)
if my_person.first_name is None:
   my_person.first_name = 'John'

But the code fails saying my_person does not have attribute first_name (or whatever other attribute I try).

  • 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-15T09:23:58+00:00Added an answer on June 15, 2026 at 9:23 am

    The following works:

    @classmethod
    def get_person(self, _last_name, _max_height):
     a_person = Person.query(
           ndb.AND(
              Person.last_name == _last_name,
              Person. height == _max_height
       ))
      return a_person.get()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For the example under Friend Functions How is the following true? Notice that neither
I’ve only been trying it in Firefox’s JavaScript console, but neither of the following
I have the following code alternatives, neither of which is satisfactory. I'm using jQuery
I've a normal Java class (neither a JSP nor a Servlet) that performs some
I have a problem set for my programming class which I'm working on. The
I'm having trouble using generics. Given the following example : class A<T> { public
I have started working with pathogen.vim with gvim on Windows, following Tim Pope's setup
I have a few questions about the linkage from the following variables. By examples
I am stuck with the following problem: I have the two following correct working
We have following markup <input type=checkbox class=foo /> <input type=checkbox class=foo /> <input type=checkbox

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.