background preloader

How not to write Python code » Ikke’s blog

How not to write Python code » Ikke’s blog
Lately I’ve been reading some rather unclean Python code. Maybe this is mainly because the author(s) of the code had no in-depth knowledge of the Python language itself, the ‘platform’ delivered with cPython,… Here’s a list of some of the mistakes you should really try to avoid when writing Python code: Some days ago RealNitro pointed me at this list of essential Python readings. “Idiomatic Python” is a must-read, even for experienced Python developers. That’s about it for now, maybe I’ll add some more items to this list later on. Posted in Development, Technology. Tagged with Development, python. By Nicolas – February 8, 2008

PyCON FR Graphviz 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 a resident of Montreal,father of two great kids, husband of one special woman,a full-time Python programmer,author of the Docutils project and reStructuredText,an editor of the Python Enhancement Proposals (or PEPs),an organizer of PyCon 2007, and chair of PyCon 2008,a member of the Python Software Foundation,a Director of the Foundation for the past year, and its Secretary. In the tutorial I presented at PyCon 2006 (called Text & Data Processing), I was surprised at the reaction to some techniques I used that I had thought were common knowledge. Many of you will have seen some of these techniques and idioms before. These are the guiding principles of Python, but are open to interpretation. import this

Essential Python Reading List Here’s my essential Python reading list. I’ve tried to order the items so you can pause or stop reading at any point: at every stage you’ll have learned about as much possible about Python for the effort you’ve put in. The Zen of Python The Zen of Python is so short I can include it here in its entirety. Typing import this in an interpreted session gives a pythonic spin on “Hello, world”. >>> import this The Zen of Python, by Tim Peters Beautiful is better than ugly. If this doesn’t ring true, Python isn’t for you. Python Tutorial Your next stop should be the Python tutorial. start here The latest version (by which I mean the version corresponding to the most recent stable release of Python) can be found on the web at but I recommend you find and bookmark the same page from your local Python installation: it will be available offline, pages will load fractionally quicker, and you’re sure to be reading about the version of Python you’re actually running. What’s New?

Distutils-SIG Charter The Distutils-SIG exists to discuss the design, implementation, and maintenance of a suite of module distribution utilities for Python. These utilities are grouped in the 'distutils' package in Python. The goal of distutils is to make building, packaging, distributing, and installing Python modules, extensions, and applications painless and standardized. There are also third-party tools built on the top of distutils, that are using the Distutils mailing list as their home. Namely: setuptools zc.buildout If you are packaging a Python package, this SIG is probably a good starting point to ask questions. The goal of Distutils-SIG is also to try to catch the good bits and practices from third-party projects and insert them in Distutils itself to serve the community. What's Available Interested in learning more or trying out the Distutils?

Les romans audio et pdf d' Honoré de Balzac Nous ne détaillerons pas ici la biographie de l'écrivain, celle ci est suffisamment décrite dans une multitude d'articles ou de revues, Balzac est avant tout, le précurseur de la littérature moderne. Tout comme Emile Zola, qui fit l'étude, par l'intermédiaire d'une vingtaine de romans, de l'influence sous le second empire, des tares génétiques au travers de la saga d'une famille " Les Rougon-Macquart". Balzac est un personnage à géométrie variable et il est très intéressant de cerner sa personnalité et son caractère dans les quelques pages qui suivent. C'est au travers d'un projet littéraire et d'une immense fresque qui dépeint la société du dix neuvième siècle, qu' "En 1845, honoré de Balzac décida de réunir toute son oeuvre sous le titre: La Comédie Humaine, titre qu'il emprunta peut-être à Dante ou à Vigny... * Etudes de moeurs 1. 2. 3. 6. 8.

PEP 257 -- Docstring Conventions What is a Docstring? A docstring is a string literal that occurs as the first statement in a module, function, class, or method definition. Such a docstring becomes the __doc__ special attribute of that object. All modules should normally have docstrings, and all functions and classes exported by a module should also have docstrings. Public methods (including the __init__ constructor) should also have docstrings. String literals occurring elsewhere in Python code may also act as documentation. String literals occurring immediately after a simple assignment at the top level of a module, class, or __init__ method are called "attribute docstrings".String literals occurring immediately after another docstring are called "additional docstrings". Please see PEP 258, "Docutils Design Specification" , for a detailed description of attribute and additional docstrings. XXX Mention docstrings of 2.2 properties. For consistency, always use """triple double quotes""" around docstrings. To illustrate:

ctypes tutorial Note: The code samples in this tutorial uses doctest to make sure that they actually work. Since some code samples behave differently under Linux, Windows, or Mac OS X, they contain doctest directives in comments. Note: Quite some code samples references the ctypes c_int type. This type is an alias to the c_long type on 32-bit systems. So, you should not be confused if c_long is printed if you would expect c_int - they are actually the same type. ctypes exports the cdll, and on Windows also windll and oledll objects to load dynamic link libraries. You load libraries by accessing them as attributes of these objects. cdll loads libraries which export functions using the standard cdecl calling convention, while windll libraries call functions using the stdcall calling convention. oledll also uses the stdcall calling convention, and assumes the functions return a Windows HRESULT error code. Windows appends the usual '.dll' file suffix automatically. >>> getattr(cdll.msvcrt, "?? >>> pi[0] 99 >>>

Related: