cannot concatenate ‘str’ and ‘NoneType’ objects

The cause of this error may run deep in your code, but if you simply wish to have and error free interface on the front end, you can cast any NoneType object to an empty string:

str(myVar)

'this demonstrates casting a none to a string' + str(couldBeANoneType)

Why follow me on Twitter?

  • I tweet about new technologies, services or libraries I find interesting
  • Yeah, sometimes I'll post a pet-peeve or rant about something trivial
  • If I discover something that made my web development life easier, I share it
  • I'll shout out any handy tip that I think might be useful to other devs
  • Very rarely anything promotional


This entry was posted in Python. Bookmark the permalink.

Updated: 2011-09-23

Phil LaNasa follow us in feedly