The subclass needs a way to access parent class.
super
is the parent class.
—-
def save(self):
# do something specific customized actions for the model
super(Card, self).save() #perform parent class’s save
——-
The subclass needs a way to access parent class.
super
is the parent class.
—-
def save(self):
# do something specific customized actions for the model
super(Card, self).save() #perform parent class’s save
——-
get( )
is a method available on any Python dictionary, letting you ask for the value of a particular key and specify a default to fall back on if the key doesn’t exist.
e.g.,
query=request.GET.get(‘q’,”)
If there is no q, then query becomes empty string.
use brackets
e.g.,
request.GET['q']
For classes:
use capitalized names, camel-style for multiword names
e.g., Context, HttpResponse
For modues, funtions and normal variables:
use lowercase names and underscore to seprate multiple words,
e.g., get_absolute_url
Python functions have no explicit begin or end, and no curly braces to mark where the function code starts and stops. The only delimiter is a colon (:) and the indentation of the code itself.
This corresponds with def and if etc.
For example,
—
def fib(n):print 'n =', n
if n > 1:
return n * fib(n - 1) else:
print 'end of the line' return 1
PIL
is
Python Imaging Library.
It is needed for many other tools/plugins (e.g., image uploader etc.)
Download the Windows installer (.exe) from PyPI: http://pypi.python.org/packages/any/M/Markdown/Markdown-2.0.win32.exe
is a Python HTML/XML parser designed for quick turnaround projects like screen-scraping.
Looks good for blogging export/import tool.
How to make comment in Python?
There are two ways to make comments in Python.
1.
# single line comment
2.
“”"
multiple line comments
here
“”"