In Python we can make use of Nmap through the python-nmap library, which allows us to manipulate the results of a scan easily. In addition, it can be a perfect tool for system administrators or computer security consultants when it comes to automating penetration-testing processes.
python-nmap is a tool that is used within the scope of security audits or intrusion tests and its main functionality is to discover what ports or services a specific host has open for listening. In addition, it has the advantage that it is compatible with versions 2.x and 3.x.
You could get the source for python-nmap from the Bitbucket repository:
https://bitbucket.org/xael/python-nmap
The latest version of python-nmap can be downloaded from the following websites: