On Thu, Oct 10, 2013 at 5:12 PM, Peter Cacioppi <peter.cacio...@gmail.com> wrote: > I'm trying to think of a good example usage of echo-argument and. Maybe > something like > > possible = foo and foo.allowsit() > if (possible is None) : > print "foo not provided" > if (possible is False) : > print "foo doesn't allow it" > > A bit awkward, echo-argument or is more naturally useful to me then > echo-argument and.
first_element = some_list[0] # Oops, may crash try: first_element = some_list[0] except IndexError: firstelement = None # A bit verbose first_element = some_list and some_list[0] # or if you want a zero instead of an empty list: first_element = len(some_list) and some_list[0] Also, consider the case where you have a function, or None: result = func(*args,**kwargs) # NoneType is not callable result = func and func(*args,**kwargs) ChrisA -- https://mail.python.org/mailman/listinfo/python-list