On Mon, Mar 8, 2010 at 4:20 PM, Colin <[email protected]> wrote: > The "User Authentication with PostgreSQL database" tutorial in > web.py's documentation includes the following function: > > def logged(): > if session.login==1: > return True > else: > return False > > Which is execrable, and the kind of thing you learn to stop writing in > a first-year programming course. For the sake of encouraging good > coding habits and having documentation that reflects well on web.py, > I'd suggest changing this to the one-liner that it should be.
I never went to school, and I'm not a very experienced Pythonista, so I have to ask, for the sake of learning: What is bad about it? I myself would: store truth value in session.login, so that it returns useful data if it's True (like if session.login == user record, then it's True and we get useful info as a bonus), and of course, if it's None, then it's False at the same time. -- Branko Vukelić http://foxbunny.tumblr.com/ http://www.flickr.com/photos/16889...@n04/ http://www.twitter.com/foxbunny http://github.com/foxbunny -- You received this message because you are subscribed to the Google Groups "web.py" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/webpy?hl=en.
