Skip to content

except exception? #508

@kw-andy

Description

@kw-andy

I've created this function

def cre_file_conn(ip_addr,username,priv_keys):
    try:
        cmd = ("ssh -i {} {}{}{}").format(priv_keys,username,"@",ip_addr)
        child = pexpect.spawn(cmd)
        child.expect(username)
        child.sendline('touch 123toto.txt')
        child.expect(username) 
        child.sendline('exit')
    except Exception as e:
        print(str(e))       

The except Exception as e works well. But I was not able to find the mention on the docs.

What is the difference between except Exception as e and except pexpect.EOF as e?

I know that except pexpect.EOF as e will try to catch all EOF. But how about except Exception?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions