On Sun, Nov 15, 2009 at 6:39 AM, Timo List <[email protected]> wrote:
> For my program I disable the py2exe log feature by routing output to the
> nul-file.
> Code:
>
> if win32 and py2exe:
> sys.stdout = open("nul", "w")
> sys.stderr = open("nul", "w")
>
> This always worked fine.
>
> Today, I received an email from a user with the following error:
> IOError: [Errno 2] No such file or directory: 'nul'
>
> Now, I thought the nul-file always existed, shouldn't it?
> Is there another way to disable output, if this one fails?
>
Just try/except:
try:
#put your code here
except IOError:
#don't save, print a message, whatever you want to do
#if you want to propagate the error, uncomment next line
#raise
HTH,
Wayne
--
To be considered stupid and to be told so is more painful than being called
gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness,
every vice, has found its defenders, its rhetoric, its ennoblement and
exaltation, but stupidity hasn’t. - Primo Levi
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor