background preloader

Wiki, Blog

Facebook Twitter

Awesome Python. Anti-Patterns in Python Programming - Constantine Lignos. This page is a collection of the most unfortunate but occasionally subtle issues I've seen in code written by students new to writing Python.

Anti-Patterns in Python Programming - Constantine Lignos

It's written to help students get past the phase of writing ugly Python code and understand some of the most common idioms. The simplifications employed (for example, ignoring generators and the power of itertools when talking about iteration) reflect its intended audience. There are always reasons to use some of these anti-patterns, which I've tried to give those where possible, but in general using these anti-patterns makes for less readable, more buggy, and less Pythonic code. If you're looking for broader introductory materials for Python, I highly recommend The Python Tutorial or Dive into Python. If you have comments or wish to use this work in way other than what the license allows, feel free to get in touch with me by e-mail.

The use of range for i in range(len(alist)): print alist[i] for item in alist: print item Why do this? Loops. Chase Seibert. Welcome to Python by Example! — Python by Example. Mathematics, philosophy, code, travel and everything in between. Google App Engine is a pretty interesting PaaS offering.

Mathematics, philosophy, code, travel and everything in between.

However, its Python environment leaves a lot to be desired. The biggest pain point is its seeming incompatibility with virtualenv – a tool that is almost indispensable in Python development. Luckily, there is a workaround. Virtual environments are perfect for isolating your project from the global Python installation and managing its package dependencies separately. Unfortunately, most App Engine guides will tell you to “just download package ZIPs and unpack them in your project directory.” App Engine SDK doesn’t play nice with virtualenv because it’s a sandbox trying to emulate the environment on GAE production servers. The workaround tl;dr: get linkenv to symlink virtualenv packages to your project dir. When you deploy an app to GAE the deploy script will resolve any symbolic links inside your project directory and upload their actual targets. Step 1 is easy: To automate step 2 I’ve created a small script called linkenv.

MarginHound - Barking About Python and Analytics. Codematician. Getting to know Python is a pretty hairy task, as is diving into any language.

Codematician

Fortunately Python is considered an easy language to learn and the potential for using it in HPC settings is pretty large. Below I give an introduction to learning, speeding, and scaling Python. Each topic can be the subject of its own book, so take these talking points and notes as only hints to what one can look at. For a very detailed view of this topic for scientists I recommend the following three books: <Stuff about="code" /> Adventures across space and time with the Python programming language. The “Invent with Python” Blog. I've written an article for OpenSource.com called APIs, not apps: What the future will be like when everyone can code, where I write about a coming future where programming ability is in the hands of everyone.

The “Invent with Python” Blog

Excerpt: Despite this hype, I do think that coding will become a more widespread and routine skill in the years to come. Fetchez le Python. Intermediate and Advanced Software Carpentry in Python. Welcome!

Intermediate and Advanced Software Carpentry in Python

You have stumbled upon the class handouts for a course I taught at Lawrence Livermore National Lab, June 12-June 14, 2007. These notes are intended to accompany my lecture, which was a demonstration of a variety of "intermediate" Python features and packages. Because the demonstration was interactive, these notes are not complete notes of what went on in the course. (Sorry about that; they have been updated from my actual handouts to be more complete...)

However, all 70 pages are free to view and print, so enjoy. Online Python Tutor. 01000011 01010011 01000011. Hidden features of Python. Python. New Coder – five life jackets to throw to the new coder. Python Tips, Tricks, and Hacks. COMP-E. Understand Your Code. Nadia Alramli's Blog. Gaël Varoquaux. Happy new year, every one. I have just released Joblib 0.6.0 beta. The highlights of the 0.6 release are a reworked enhanced pickler, and Python 3 support. Many thanks go to the contributors to the 0.5.X series (Fabian Pedregosa, Yaroslav Halchenko, Kenneth C. Arnold, Alexandre Gramfort, Lars Buitinck, Bala Subrahmanyam Varanasi, Olivier Grisel, Ralf Gommers, Juan Manuel Caicedo Carvajal, and myself). Fernando Perez. Python - Le cyberblog du coyote. Quelles règles les programmeurs débutants devraient-ils toujours respecter ?

Python - Le cyberblog du coyote

Un développeur expérimenté livre ses 7 règles d'or A ses débuts, le programmeur inexpérimenté a tendance à fixer son attention sur la fonctionnalité à produire, quelque soit la quantité de ligne de code, les procédures et les fonctions utilisées pour produire le résultat final. Et ceci sans comprendre (parfois) ce qu'il fait vraiment ou les spécificités du langage. Paul Vick, un développeur reconnu et spécialisé dans les bases de données et les langages, a travaillé sur plusieurs produits Microsoft dont SQL Server, Visual Basic ou le runtime .NET.

Dans un billet de blog, il s'est inspiré des « sept règles pour les écrivains débutants » pour en proposer une version aux jeunes développeurs et leur éviter de faire trop d'erreurs. Règle numéro 1, le programmeur débutant ne doit pas écrire de longues procédures. Deux, chaque procédure doit avoir un objectif clair. Sources : Developpez.com, Blog de Paul Vick.