background preloader

Style Guide for Python Code

Style Guide for Python Code
Code should be written in a way that does not disadvantage other implementations of Python (PyPy, Jython, IronPython, Cython, Psyco, and such).For example, do not rely on CPython's efficient implementation of in-place string concatenation for statements in the form a += b or a = a + b. This optimization is fragile even in CPython (it only works for some types) and isn't present at all in implementations that don't use refcounting. 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.Also, 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!

Python Library From OSGeo Wiki Motivation Several OSGeo software projects support Python. Elements and Element Trees Fredrik Lundh | Last updated July 2007 This note introduces the Element, SubElement and ElementTree types available in the elementtree library. For an overview, with links to articles and more documentation, see the ElementTree Overview page. For an API reference, see The elementtree.ElementTree Module. You can download the library from the downloads page.

Beautiful Soup: We called him Tortoise because he taught us. [ Download | Documentation | Hall of Fame | For enterprise | Source | Changelog | Discussion group | Zine ] You didn't write that awful page. You're just trying to get some data out of it. python3 How to Think Like a Computer Scientist — How to Think Like a Computer Scientist: Learning with Python 3 Version date: October 2012 by Peter Wentworth, Jeffrey Elkner, Allen B. Downey, and Chris Meyers (based on 2nd edition by Jeffrey Elkner, Allen B. Downey, and Chris Meyers) Corresponding author: PyQL : a new set of Python wrappers for QuantLib | Things and thoughts Hi folks, We are happy to announce the release of PyQL [1], a new set of Python wrappers for QuantLib. The project is available here : * URL: * License: BSD license. * Authors: Didrik Pinte, Enthought and Patrick Henaff, IAE Paris. Why another set of Python wrappers for QuantLib?

» Python Web Frameworks: Are Template Languages Worth using, or is Python enough? - DevChix - Blog Archive Last year I was tasked with the job of evaluating web frameworks and template languages, picking a set of tools, and using them to rewrite chunks of our web framework, one chunk at a time. It was a fun project (thanks be to Bill). I had months to try out various frameworks, content servers and template languages before we committed to anything and moved forward. With respect to the web framework itself, certain things swayed my decision. Code Like a Pythonista: Idiomatic Python In this interactive tutorial, we'll cover many essential Python idioms and techniques in depth, adding immediately useful tools to your belt. There are 3 versions of this presentation: ©2006-2008, licensed under a Creative Commons Attribution/Share-Alike (BY-SA) license. My credentials: I am

python 2.x How to Think Like a Computer Scientist — Learning with Python 2nd Edition Navigation How to Think Like a Computer Scientist¶ Learning with Python¶ 2nd Edition (Using Python 2.x) by Jeffrey Elkner, Allen B. Downey, and Chris Meyers Documentation QuantLib reference manual [HTML] The reference manual is also available for offline reading from the SourceForge download page Books Instant Python This is a minimal crash-course in the programming language Python. To learn more, take a look at the documentation at the Python web site,; especially the tutorial. If you wonder why you should be interested, check out the comparison page where Python is compared to other languages. This introduction has been translated into several languages, among them Portuguese, Italian, Spanish, Russian, French, Lithuanian, Japanese, German and Greek, and is currently being translated into Norwegian, Polish, and Korean.

HowTo/Sorting Original version by Andrew Dalke with a major update by Raymond Hettinger Python lists have a built-in sort() method that modifies the list in-place and a sorted() built-in function that builds a new sorted list from an iterable. There are many ways to use them to sort data and there doesn't appear to be a single, central place in the various manuals describing them, so I'll do so here. 10 Python pitfalls (or however many I'll find ;-) These are not necessarily warts or flaws; rather, they are (side effects of) language features that often trip up newbies, and sometimes experienced programmers. Incomplete understanding of some core Python behavior may cause people to get bitten by these. This document is meant as some sort of guideline to those who are new to Python. It's better to learn about the pitfalls early, than to encounter them in production code shortly before a deadline. :-} It is *not* meant to criticize the language; as said, most of these pitfalls are not due to language flaws. 1.

Machine Learning Cheat Sheet (for scikit-learn) As you hopefully have heard, we at scikit-learn are doing a user survey (which is still open by the way). One of the requests there was to provide some sort of flow chart on how to do machine learning. As this is clearly impossible, I went to work straight away. This is the result: [edit2] clarification: With ensemble classifiers and ensemble regressors I mean random forests, extremely randomized trees, gradient boosted trees, and the soon-to-be-come weight boosted trees (adaboost). [/edit2]

Related:  Python