Help function in python

By | June 26, 2020

I found Help function in python comes handy to get quick information about the different modules and its classes used in any of our program. The syntax is as follow.

Syntax :


arguments can be : module, function, class

i am going to use help function to explore the information on paramiko module. As shown below, we have imported the paramiko module in the python interactive interpreter and used paramiko as an agrument within the function. The output show the package contents and its classes with example.

>>> import paramiko

>>> help(paramiko)


# This file is part of paramiko.
# Paramiko is free software; you can redistribute it and/or modify it under the

-- output omitted---


-- output omitted---

We can also use help interactive session for the same purpose. This can be done by executing help function without any argument as shown below.

>>>> help()

help> paramiko.SSHClient

Help on class SSHClient in paramiko

paramiko.SSHClient= class SSHClient(paramiko.util.ClosingContextManager)
| A high-level representation of a session with an SSH server. This class
| wraps .Transport, .Channel, and .SFTPClient to take care of most
| aspects of authenticating and opening channels. A typical use case is::
| client = SSHClient()
| client.load_system_host_keys()
| client.connect('')
| stdin, stdout, stderr = client.exec_command('ls -l')
| You may pass in explicit overrides for authentication and server host key
| checking. The default mechanism is to try to use local key files or an
| SSH agent (if one is running).

| Method resolution order:
| SSHClient
| paramiko.util.ClosingContextManager
| builtins.object

-- output omitted---
| connect(self, hostname, port=22, username=None, password=None, pkey=None, key_filename=None, timeout=None, allow_agent=True, look_for_keys=True, compress=False, sock=None, gss_auth=False, gss_kex=False, gss_deleg_creds=True, gss_host=None, banner_timeout=None, auth_timeout=None, gss_trust_dns=True, passphrase=None, disabled_algorithms=None)
| Connect to an SSH server and authenticate to it. The server's host key
| is checked against the system host keys (see load_system_host_keys)
| and any local host keys (load_host_keys). If the server's hostname
| is not found in either set of host keys, the missing host key policy
| is used (see set_missing_host_key_policy). The default policy is
| to reject the key and raise an .SSHException

So now by looking at the above output and with little bit of search on internet [ ], we can easily create simple program to SSH into EC2 instance [ i have used here linux academy lab credential to spin up the instance in AWS] and get the details of linux version/distribution running on connected instance.

Let’s run the script.

Output :


Linux version 4.18.0-193.el8.x86_64 ( (gcc version 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC)) #1 SMP Fri Mar 27 14:35:58 UTC 2020

One thought on “Help function in python

Leave a Reply

Your email address will not be published. Required fields are marked *