This page contains basic beginner and more advanced Python snippets. The purpose of this page is two fold; a reference for those who are learning and like to learn via pure code, as well as, a location for mpettersson to keep snippets and Python related links. This pages subsections are:
Python 101
Miscellaneous Python Classes & Code
Python Resources
As always, please contact us with comments, concerns, questions, etc. about Python!

Python 101

Python downloads for Windows can be found on the Python Releases for Windows page, similarly, downloads of Python for Mac are on the Python Releases for Mac OS X page, and the catch all, or general Python download page is at There are two major versions of Python, where “Python 2.x is legacy, Python 3.x is the present and future of the language”. For Python documentation, such as tutorials, visit Python’s documentation page. For an Integrated Development Environment (IDE) checkout either Eclipse or NetBeans, and refer to the Python IDE wiki for compatibility and Python specific plugins.

and as assert break class continue
def del elif else except exec
finally for from global if import
in is lambda not or pass
print raise return try while with

Please note that the following snippets, Python 101 and Python 101 Continued, are the code and none of the extra fluff of the tutorials that can be found in Python 2.7.9 Documentation for The Python Tutorial.

NOTE: In the following code snippets, a ‘>>>’ indicates the Python interpreter prompt.


Miscellaneous Python Code

This section contains random Python snippets.

The following (two) scripts were created when investigating web security vulnerabilities; we wanted to get some information out of the CVE list and (of course) we didn’t want to manually parse them… This is what Python is made for!

The following script is used to tally the number of CVEs (given the output of the previous script).


Python Resources

This will contain some recommended Python links and resources.

Leave a Reply