skip Trackback error for ftp checking
rosuav at gmail.com
Mon Nov 12 11:23:00 CET 2012
On Mon, Nov 12, 2012 at 8:25 PM, moonhkt <moonhkt at gmail.com> wrote:
> On Nov 10, 2:50 pm, Steven D'Aprano <steve
> +comp.lang.pyt... at pearwood.info> wrote:
>> The same way you would skip any other error when you do something wrong:
>> catch the exception.
> Thank. Added below.
> ftp = FTP(options.remote_host_address)
> except :
> print "Host address not found."
Heh, I'm afraid that's not quite what Steven meant; what you're doing
there is literally skipping _any other error_. A bare except is
usually not a good thing. Catch the specific exception you want to
catch - that way, if you typo a name or something, you don't get an
obscure message about the host address when it's really a coding bug.
More information about the Python-list