views:

76

answers:

1

I have this class:

class View(object):
    def main_page(self, extra_placeholders = None):
     file = '/media/Shared/sites/www/subdomains/pypular/static/layout.tmpl'

     placeholders = { 'site_name' : 'pypular' } 

     # If we passed placeholders vars, append them
     if extra_placeholders  != None:
      for k, v in extra_placeholders.iteritems():
       placeholders[k] = v

My problem in the code above is the if statement

As you can see, the function takes an argument(extra_placeholders) which is a dict.

If i don't pass a parameter to main_page(),

if extra_placeholders  == None:
    return 'i executed'

runs fine. however,

if extra_placeholders  != None:
    return 'i cause error'

does not work. it causes a 500 internal server error. Why?

+1  A: 

should you be using instead

if !( extra_placeholders  is  None) :

See here

Edit: To reflect comment:

It appears (thanks) that you can also use:

 if extra_placeholders  is  not None :
Preet Sangha
Thank you. "is not None" seems to have done it too.
lyrae
And thanks for that link. really clarified some things up!
lyrae