Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are the error_perm and msg in "except error_perm, msg" special?

I'm reading this script. It synchronizes files via FTP.

I'm confused with this statement in line 106

try:
    ...
except error_perm, msg:
    ...

It seems the variables error_perm and msg come from nowhere. When the try part goes wrong, the script halts and fails to go into the except part.

like image 443
zjk Avatar asked Nov 23 '25 04:11

zjk


1 Answers

You have the next import on the top of the file:

from ftplib import FTP, error_perm

error_perm is an error class.

statement

except error_perm, msg:

catches any exception with type error_perm and stores exception object in variable msg.

like image 83
Roman Bodnarchuk Avatar answered Nov 24 '25 20:11

Roman Bodnarchuk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!