On Fri, Feb 20, 2015 at 5:18 PM, Paul Rubin <no.email@nospam.invalid> wrote: > Empty string would be bad. Sometimes I like to simulate an option type, > by returning the value as a 1-element list if there's a value, otherwise > as an empty list. So you could say > > filename = get_filename(...)[0] > > if you want an exception in the failure case, or you could do something > like > > fs = get_filename(...) > if len(fs) == 0: ... # didn't get a filename
Bikeshedding: That could be written as simply "if not fs". :) ChrisA -- https://mail.python.org/mailman/listinfo/python-list