Python Knowledge Base. here is the archive of the defunct site:
[defunct]: www.faqts.com has a lot of
example code using dictionaries.
(FAQTS : Computers : Programming : Languages : Python)
and both of the defunct url's work appended to that archive url
also, the example code was part of
a snippets library:
here is the help on operating on files;
# the directory of the currently executing program:7.21: news.cyb/dev.py/style guide has some pragma too:
import sys, os
if __name__ == '__main__':
_thisDir = sys.argv
_thisDir = sys.modules[__name__].__file__
_thisDir = os.path.split(_thisDir)
. the python style guide is more than just formatting;
it has some pragmas and gotcha warnings too;
eg, Programming Recommendations:
Code should be written in a way that does not disadvantage7.14: bk.cyb/dev.py/lists:
other implementations of Python
(PyPy, Jython, IronPython, Cython, Psyco, and such).
do not rely on CPython's efficient implementation of
in-place string concatenation for
statements in the form a += b or a = a + b.
Those statements run more slowly in Jython.
In performance sensitive parts of the library,
the ''.join() form should be used instead.
This will ensure that concatenation occurs in
linear time across various implementations.
Comparisons to singletons like None
should always be done with is or is not,
never the equality operators.
beware of writing if x
when you really mean if x is not None
-- e.g. when testing whether a variable or
argument that defaults to None
was set to some other value.
The other value might have a type (such as a container)
that could be false in a boolean context!
. index starting at 0(zero) means an insert(i, obj)
is the same as putting an obj after the ith item .
. list + list2
= list`insert(-1, list2) .
. notice how stack is related to list:
pop = un(right-most element)
pop = un push;
push = append .
. which is the opposite of append:
is pop removing the right-most ?
9.6: yes, list.pop() is un-append;
pop() takes the right-most .
. list.remove(elem) finds an item equal to the given elem;
contrast that to L.pop(i), removes the ith element .
-- remove() searches for the first instance
(throws ValueError if not present).
. see the usage of __all__ (a list)7.16: news.cyb/dev.py/testing/windmill:
in the __init__.py for packages .
If __all__ is defined in __init__.py,
and you use "from my_package import *"
then only the modules/variables defined in __all__
will be loaded.
>>> import os
mikeal 2009`intro to windmill:
. Windmill is a Selenium competitorWindmill`intro:
with test-writing support for both.
. Windmill is a web testing tool. more encouragement 2011:
designed to let you painlessly automate
and debug your web application.
Originating at the Open Source Applications Foundation
Windmill was built to help QA
keep up with the rapid release cycles
of the Chandler Server Web UI (Cosmo) project.
As the Cosmo client is heavy in
Windmill makes the communication
between the service and the client code
Windmill Test Framework:
. Cross-browser test recorder
Record, edit, playback and interact with your tests
from one simple interface.
. Also check out the DOM Explorer, Assertion Explorer
and fully integrated Firebug-Lite.
Interact from a python shell with the
browser and the windmill service .
. install ipython and automatically get
an even more usable shell.
"( Selenium 2 and Python
- ok so Windmill is my new favorite:
This looks interesting!:
Update: Windmill is more fun now .)