Python Notes: Difference between revisions
From Federal Burro of Information
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 3: | Line 3: | ||
* Latest: docs.python.org | * Latest: docs.python.org | ||
* Old release http://docs.python.org/release/2.2.1/lib/module-cgi.html | * Old release http://docs.python.org/release/2.2.1/lib/module-cgi.html | ||
== ghetto command line argv == | |||
<pre> | |||
#!/usr/bin/python | |||
import sys | |||
print 'Number of arguments:', len(sys.argv), 'arguments.' | |||
print 'Argument List:', str(sys.argv) | |||
</pre> | |||
== what's in that object? == | == what's in that object? == |
Revision as of 04:39, 24 March 2017
Docs:
- Latest: docs.python.org
- Old release http://docs.python.org/release/2.2.1/lib/module-cgi.html
ghetto command line argv
#!/usr/bin/python import sys print 'Number of arguments:', len(sys.argv), 'arguments.' print 'Argument List:', str(sys.argv)
what's in that object?
https://download.tuxfamily.org/jeremyblog/diveintopython-5.4/py/apihelper.py
then use it like this:
#!/usr/bin/env python from apihelper import info mything info(mything)
AutoVivification
import pprint class Vividict(dict): def __missing__(self, key): value = self[key] = type(self)() return value d = Vividict() d['foo']['bar'] d['foo']['baz'] d['fizz']['buzz'] d['primary']['secondary']['tertiary']['quaternary'] pprint.pprint(d)
vim tabs
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4