Learn about Redis and Twitter filters in Python or Ruby on myNoSQL, a blog focused on NoSQL.
Showing posts with label python. Show all posts
Showing posts with label python. Show all posts
-
-
Read Redis and Python on myNoSQL, a blog focused on NoSQL.
-
Just a quick reference for coding Python with style:
>> import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
- PEP8 - Style Guide for Python Code
- PEP256 - Docstring Processing System Framework
- PEP257 - Docstring Conventions
- PEP258 - Docutils Design Specification
- PEP287 - reStructuredText Docstring Format
What other languages (except Java) are offering something similar?
-
Do you know what a Python Virtual environment is?
Python Virtual Environment: providing a means of having multiple isolated environments for the one Python installation on a system, such that it would be possible to run different applications on the same system, but using different sets of installed Python packages.
I've always asked myself how is this thing done in Python and Pylons with its
go-pylons.py
was the first I've found offering a solution. Then, I've found some more solutions.Virtualenv, a solution developed by Ian Bicking, replacing the now deprecated workingenv and
basedinspired by virtual-python, seems to be the preferred solution (even if the comments on Ian's blog are still reporting issues).Another option is documented by Graham Dumpleton and is introduced as the poor man's solution as it is pretty manual and it involves the manipulation of
PYTHONPATH
and the creation of a set of predefined symlinks.As such setting the PYTHONHOME environment seems to be a simpler and more deterministic way of specifying where the Python lib directory is located, avoiding the need to perform fixups to the Python executable on MacOS X.
As to how to setup a Python virtual environment based on using the PYTHONHOME environment variable, for UNIX based systems it is just a matter of creating a parallel copy of the installed Python installation using symlinks. In some respects it is therefore quite similar to the original virtual-python, except that the Python executable itself is also just a symlink and not a copy.
Even if none of the above solutions seems to be 100% bullet proof, I do believe that they may prove quite useful for developing or maintaining projects relying on many dependencies and needing a stable environment.
Python 2.6 implements PEP370: Per-user site-packages directory. While the PEP doesn't directly address the virtual environments, it is introducing the possibility to control this directory through a new env variable
PYTHONUSERBASE
, which means that setting this variable to the desired location will in fact provide the solution.