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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:23:51+00:00 2026-05-27T06:23:51+00:00

In my Python-coded AppEngine application, I’m getting the following error code: NameError: global name

  • 0

In my Python-coded AppEngine application, I’m getting the following error code:

NameError: global name ‘PandaHugs’ is not defined

I can’t figure out why, as I define ‘PandaHugs’ above the place where it is called. Here’s the code:

#!C:\Python25\python.exe -u

import wsgiref.handlers
from google.appengine.ext import db
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

class PandasHugs(db.Model):
    message = db.StringProperty(required=False, multiline=False)

class MainPage(webapp.RequestHandler):
    def get(self):
        ListOfHugs = db.GqlQuery("SELECT * FROM PandasHugs")
        Adder = 0
        for PandasHugs in ListOfHugs:
            Adder = Adder + 1
        self.response.out.write('<html><body>')
        self.response.out.write('<h6>Panda has ' + str(Adder) + ' hugs!</h6>')
        self.response.out.write("<form action=\"/HugPanda\" method=\"post\"><div><input type=\"text\" name=\"PandaMessage\" value=\"A message for a panda.\"></div><div><input type=\"submit\" value=\"Hug a panda?\"></div></form></body></html>")


class HugAPanda(webapp.RequestHandler):
    def post(self):
        TheMessage = self.request.get('PandaMessage')
        HugForAPanda = PandaHugs(message=TheMessage)
        HugForAPanda.put()
        self.redirect('/main')

application = webapp.WSGIApplication(
  [('/', MainPage), ('/main', MainPage), ('/HugPanda', HugAPanda)],
  debug=True)

def main():
  run_wsgi_app(application)

if __name__ == "__main__":
  main()

Does anybody know why this is happening?

  • 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-27T06:23:52+00:00Added an answer on May 27, 2026 at 6:23 am

    You define the class PandasHugs early in your code, but later you have:

    HugForAPanda = PandaHugs(message=TheMessage)
    

    Notice the singular form of Panda? What you want is

    HugForAPanda = PandasHugs(message=TheMessage)
    

    Edit: You also have for PandasHugs in ListOfHugs: in the get() method of your MainPage class. While there is technically nothing wrong with using the class name as a local variable of your method, it is confusing and hides the PandasHugs class in the get() method. Can I suggest something like for hug in ListOfHugs?

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

Sidebar

Related Questions

http://code.google.com/appengine/docs/python/tools/uploadingdata.html is not clearly understand. Where i should call the bulkloader.py or appcfg.py? Should
I am trying to create an installer from a Python application we coded. I
I have the following Python code: import xml.dom.minidom import xml.parsers.expat try: domTree = ml.dom.minidom.parse(myXMLFileName)
http://code.google.com/intl/en/appengine/docs/python/tools/uploadingdata.html the api is : Downloading Data from App Engine To start a data
my scenario is Appengine/python/jinja/twitter-bootstrap and in this code... {% for VMS in VEP.vms_set %}
I'm trying to do the python tutorial here http://code.google.com/appengine/docs/python/gettingstarted/helloworld.html (I have python 2.5 installed)
I thought I understood the concept of cursors and queries based on http://code.google.com/appengine/docs/python/datastore/queryclass.html but
From http://code.google.com/appengine/docs/python/tools/webapp/running.html Tip: App Engine routes requests to Python scripts based on the URL
I am getting the following error in App Engine after I deployed it. Does
Are there any guidelines to writing Google App Engine Python code that would work

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.