用Python解析XML(2)
Save the code above as order.xml. Now I just need to write a parser and PDF generator script. in Python. You can use Python builtin XML parsing libraries which include SAX, minidom or ElementTree or y...
用Python解析XML(1)
One of the common tasks I am given in my day job is to take some data format input and parse it to create a report or some other document. Today we'll look at taking some XML input, parsing it wit...
用sqlalchemy构建Django连接池
As you know, Django uses new database connection for each request. This works well initially. However as the load on the server increases, creating/destroying connections to database starts taking...
Python Analyzing your Gmail with Matplotlib
Lately, I read this post about using Mathematica to analyze a Gmail account. I found it very interesting and I worked a with imaplib and matplotlib to create two of the graph they showed:•...
Python Manifold learning on handwritten digits with Isomap
The Isomap algorithm is an approach to manifold learning. Isomap seeks a lower dimensional embedding of a set of high dimensional data points estimating the intrinsic geometry of a data manifold b...
Color quantization with Python
The aim of color clustering is to produce a small set of representative colors which captures the color properties of an image. Using the small set of color found by the clustering, a quantization...
Metaclass in Python
[i=s] 本帖最后由 jieforest 于 2012-7-6 11:05 编辑 In this post we will be talking about Metaclass in python. If you are reading some code which uses metaclass, you will probably come across __ne...
Python Closures and Decorators (Part. 2)
In part 1, we looked at sending functions as arguments to other functions, at nesting functinons, and finally we wrapped a function in another function. We'll begin this part by giving an example ...
Python Closures and Decorators
Since I, in retrospect, made the wrong choice when cutting down a Python course to four hours and messed up the decorator exercise, I promised the attendants that I'd make a post about closures an...
Python实现自动化测试入门指南
This is a quick introduction to Selenium WebDriver in Python on Ubuntu/Debian systems.WebDriver (part of Selenium 2) is a library for automating browsers, and can be used from a variety of langu...
Django构建静态网页站点
If you’ve ever poked around on this blog, you may have noticed the colophon which mentions very briefly:Unlike most Django sites, this is compiled into static HTML pages bydjango-medusa, a Djan...
Django的消息中内嵌HTML
ProblemYou want to embed HTML within a message using Django's messages framework.This is a reasonably common requirement - for instance, it's common to want to include a link within the messag...
用wxPython创建自销毁面板的方法
The other day I saw a question on StackOverflow about how to dynamically destroy and create panels after a certain amount of time has passed. I told the fellow that he could use the examples from ...
Python需要配置文件吗?
I’ve never understood why people design systems in python to use config files. IMO there are two types of data and we can handle them both in dead simple ways:First: Read/write data, like UI/us...
以互动的方式学习Python
[i=s] 本帖最后由 jieforest 于 2012-6-29 09:03 编辑 One of the nicethings about programming in python is that it is free, relatively easy to use,and there is lots of support and development onlin...
Using Python to Shorten a URL Using Google's Shortening Service
Using Python to shorten a URL with Google's shortening service (goo.gl):CODE:01.#!/usr/bin/python02.# Corey Goldberg - 201003. 04.import json05.import urllib06.import urllib207. ...
Python 3.3测试版发布
Python官方发布了3.3的首个测试版本。 该版本包含了大量针对3.x分支的改进,2.x和3.x分支之间的迁移变得更加容易。该版本的主要特性包括: PEP 380:用于委托到子生成器的语法。PEP 393:灵活的字符串表示...
rst2pdf介绍 – Changing Restructured Text into PDFs with Python
There are several cool ways to create PDFs with Python. In this article we will be focusing on a cool little tool called rst2pdf, which takes a text file that contains Restructured Text and conver...
Python Timer Class - Context Manager for Timing Code Blocks
CODE:from timeit import default_timerclass Timer(object): def __init__(self, verbose=False): self.verbose = verbose  ...
Python算法-How to sort a dictionary by value
The other day I was asked if there was a way to sort a dictionary by value. If you use Python regularly, then you know that the dictionary data structure is by definition an unsorted mapping type....