How does this If conditional work in Python?
Question: 
    from google.appengine.api import users
    from google.appengine.ext import webapp
    from google.appengine.ext.webapp.util import run_wsgi_app
    
    class MainPage(webapp.RequestHandler):
        def get(self):
            user = users.get_current_user()
    
            if user:
                self.response.headers['Content-Type'] = 'text/plain'
                self.response.out.write('Hello, ' + user.nickname())
            else:
                self.redirect(users.create_login_url(self.request.uri))
    
    application = webapp.WSGIApplication(
                                         [('/', MainPage)],
                                         debug=True)
    
    def main():
        run_wsgi_app(application)
    
    if __name__ == "__main__":
        main()
    

I don't understand how this line works:

    
    
        if user:
            self.response.headers['Content-Type'] = 'text/plain'
            self.response.out.write('Hello, ' + user.nickname())
        else:
            self.redirect(users.create_login_url(self.request.uri))
    

I'm guessing the users.get_current_user() return a boolean? Then, if that is
the case how can it get a .nickname() method?

Thanks for the guidance.


Answer: It'll basically check if `user` is an actual object or `None`. If it's `None`,
the code will go into the `else` block and redirect to a "create login" page.

