troubleshooting Question

String concatenation problem

Avatar of tmonteit
tmonteitFlag for Afghanistan asked on
2 Comments1 Solution1176 ViewsLast Modified:
I'm a java guy doing my second Python 'hello world' application.    I'm doing this for GAE, but that probably isn't relevant to this problem.  

I'm trying to build an object and dump object information.  THe error I'm receiving is down annotated with the code.

1.  What's causing this error?  How should I be doing this?

2.  What's the proper (ideal) way to make an object dump information about itself.  I used to use toString() in java.
  File "/cygdrive/e/decm/", line 24, in get
    self.response.out.write('Foo 2 Generated: ' + s)
TypeError: cannot concatenate 'str' and 'instancemethod' objects
INFO     2008-07-16 18:44:05,272] "GET / HTTP/1.1" 500 -
--------------end Error---------------
# Test class
class Foo(db.Model):
  fooText = db.StringProperty(required=True, default="I am Foo")
  fooData = db.StringProperty(required=False, default="I am Foo Data")
  barRef = db.Reference(Bar, required=False)
  def dump():
    s="Text: " + self.fooText
    s+=", Data: " + self.fooData
    return s
from model import Foo
class MainPage(webapp.RequestHandler):
  def get(self):
    foo1 = Foo(fooText="MainPage Foo")
    self.response.out.write('Foo 2 Generated: ' + s)
def main():
  application = webapp.WSGIApplication([('/', MainPage)], debug=True)
if __name__ == '__main__':

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros