background preloader

Code Like a Pythonista: Idiomatic Python

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

Related:  Help and TipsPythonreference

Python Iteration Created 24 April 2012, last updated 19 March 2013 This is a presentation I gave at PyCon 2013. You can read the slides and text on this page, or open the actual presentation in your browser (use right and left arrows to advance the slides), or watch the video: A talk for PyCon 2013. This talk is billed as Beginner, and sounds like a beginner topic, but I prefer to think of it as Fundamental. Hands-On Python A Tutorial Introduction for Beginners Hands-On Python A Tutorial Introduction for Beginners Contents Chapter 1 Beginning With Python 1.1. 30 Python Language Features and Tricks You May Not Know About 1 Introduction Since I started learning Python, I decided to maintain an often visited list of "tricks". Any time I saw a piece of code (in an example, on Stack Overflow, in open source software, etc.) that made me think "Cool! I didn't know you could do that!" I experimented with it until I understood it and then added it to the list.

Python - Extension Programming with C Any code that you write using any compiled language like C, C++ or Java can be integrated or imported into another Python script. This code is considered as an "extension." A Python extension module is nothing more than a normal C library. s Python Class - Google's Python Class - Google Code Welcome to Google's Python Class -- this is a free class for people with a little bit of programming experience who want to learn Python. The class includes written materials, lecture videos, and lots of code exercises to practice Python coding. These materials are used within Google to introduce Python to people who have just a little programming experience. The first exercises work on basic Python concepts like strings and lists, building up to the later exercises which are full programs dealing with text files, processes, and http connections. The class is geared for people who have a little bit of programming experience in some language, enough to know what a "variable" or "if statement" is. Beyond that, you do not need to be an expert programmer to use this material.

PyCon 2010:The Mighty Dictionary (#55) pycon 2010 atlanta presents the mighty dictionary (#55) by brandon craig rhodes video produced by carl karsten & a team in conjunction with the psf and support from: [sauce ___ ijwbitz you too can support the psf: 9: how can python lists access every one of their items with equal speed? timeit(’mylist[o]’, my1ist = [1] * 9000’) /1 — -> 0.053692102432250977 ‘50 ns per getitern timeit(’mylist[7000]’, ‘mylist = [1] * 90001) # -- 0.051i60ø276947ø2148 —50 ns per getitem 9: how can python lists access every one of their items with equal speed? timeit(’mylist[e]’,. ‘mylist = [1] * 9000’) # --> . 53692 102432250977 5ø tis per geti tern timeit(’my1ist70o0], ‘mylist = [1) * 9000’) t ---.> 0.051468027694702748 ns per ge ti tern

Python Module of the Week The Python Module of the Week series, or PyMOTW, is a tour of the Python standard library through short examples. This is version 1.132, last updated Aug 31, 2014 to cover the ConfigParser module. Download Download version 1.132, including all source files with examples and HTML versions of the documentation. There is also a PDF of this entire document available for download. Translations

Python from Scratch – Create a Dynamic Website We’ve covered quite a bit of Python in the previous tutorials in this Session. Today, we’re going to combine everything we’ve learned so far to build a dynamic website with Python. Prefer a Video Tutorial? So, how do you get started creating websites with Python? Well, you could do it all yourself, and write a program that runs on a web server, accepting page requests and serving up responses in the form of HTML and other resources. However, that’s a lot of work, so why go to all the trouble when there are plenty of existing tools out there to do the job for you?

Default Parameter Values in Python Python’s handling of default parameter values is one of a few things that tends to trip up most new Python programmers (but usually only once). What causes the confusion is the behaviour you get when you use a “mutable” object as a default value; that is, a value that can be modified in place, like a list or a dictionary. An example:

Eric Walstad's crew quarters on the Starship Hello World! I'm busilly tuning the hyper drive right now. Please have a seat and enjoy my spartan quarters or have a look at my business site: or the Django Critter that helps me write code at the speed of light. Thanks for visiting, Eric Overview — Sarge 0.1.5.dev0 documentation Start here for all things sarge. What is Sarge for?¶ If you want to interact with external programs from your Python applications, Sarge is a library which is intended to make your life easier than using the subprocess module in Python’s standard library. Sarge is, of course, short for sergeant – and like any good non-commissioned officer, sarge works to issue commands on your behalf and to inform you about the results of running those commands. The acronym lovers among you might be amused to learn that sarge can also stand for “Subprocess Allegedly Rewards Good Encapsulation” :-)

Related:  PythonPythonGames and TutorialsMIT / EdxGood code in Python