Python

%toc

Docs

pydoc3 -b

Download https://docs.python.org/3/download.html and run webserver in the folder.

Oneliners

python -m SimpleHTTPServer

Scrapy

Scrapy Shell

Start shell: scrapy shell "http://example.com"

Search:

response.xpath('//title')

Vim

https://wiki.python.org/moin/Vim

simple template:

#!/usr/bin/env python

   """
   Python source code - replace this with a description of the code and write the code below this text.
   """

   # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

Debugger

python -m pdb myscript.py

Class

class Classname ():

       def __init__ (self):
           return 0

Argparse

QT

Try Except

try:
       # Use "raise" to raise an error
       raise IndexError("This is an index error")
   except IndexError as e:
       pass    # Pass is just a no-op. Usually you would do recovery here.
   except (TypeError, NameError):
       pass    # Multiple exceptions can be handled together, if required.
   else:   # Optional clause to the try/except block. Must follow all except blocks
       print "All good!"   # Runs only if the code in try raises no exceptions
   finally: #  Execute under all circumstances
       print "We can clean up resources here"

Django

Mozilla Tutorial

Code: https://github.com/mdn/django-locallibrary-tutorial

Pdb