On Saturday, October 29, 2011 6:58:53 PM UTC-4, Pystar wrote: > > I actually did this and it worked, > > I put this at the top of my module file: > def func(): > if auth.user == None: > return "Anon" > else: > return auth.user.first_name >
Seems like overkill, particularly if you only need to call func() once. Even if you need to re-use this elsewhere, you could do: default_name = auth.user and auth.user.first_name or 'Anon' and use default_name wherever you need it.