Dan Sommers <d...@tombstonezero.net> writes: > I'd still prefer an exception to None, and we agree on that an empty > string is bad because it's not a non-string and it could be too easily > mistaken for a filename.
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 -- https://mail.python.org/mailman/listinfo/python-list