open() and EOFError
rosuav at gmail.com
Tue Jul 8 12:29:20 CEST 2014
On Tue, Jul 8, 2014 at 7:03 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> On Mon, 07 Jul 2014 14:49:56 -0400, Terry Reedy wrote:
>> Avoid EOFError. Much better, I think, is the somewhat customary
>> s = input("Enter something, or hit <return> to exit") if not s:
>> else: <process s>
> Under many circumstances, I would do exactly that. But sometimes an empty
> string is valid data, not a signal for special processing (whether
> exiting the application, or something else).
Or you want to have two different signals: empty string means "use the
default", and something else means "exit the application now please".
More information about the Python-list