Python quick sort algorithm

The standard implementation will be

For traditional language like C and C++, this is the best we can get. But python has more powerful language feature. This program can be implemented more elegantly .

How to use Python logging module

Most python beginers only use print statement to output some messages here or there, but Python library already provided a powerful logging module. Its very beneficial to take a little while to learn about it, and then you can abandon the old school print statement forever.

A Python multi thread example

Python thread library is pretty straightforward. Here is an example.

Run "python thread.py".

Upload new files to FTP server with python

, these files are uploaded to FTP server. This script is useful when you have a directory to which new files ... time to flush new files to FTP server. You can even set a cron job to run it periodically ... FTP server. Uploading file with Python is easy and simple, to get start, you need to know ... real world examples. This Python script will scan a directory , if there are new files

Write a DFS algorithm in Python

The first step is to define a data structure represent graph in Python. The dictionary is a good choice, each key represent a node, the value is a list of nodes that connected with key.

Here is an example.

Python dictionaries dict() and {} performance

Dictionary is unordered collection. Python using hash to location element location in dictionary, its very fast to add or remove from dictionary .

Declare a dictionary, there are a lot of different to create dictionary:

Python from import syntax

A Python module , is just a python file. Thus, actually every py file you create with your code editor is a module. The only difference is that there maybe no one import your file.

Some special modules don't have their py file, like sys which is built in the Python core. Others implemented in other language like C for performance's sake.

Some special modules don't have their py file, like sys which is built in the Python core. Others implemented in other language like C for performance's .

Python load the C runtime library incorrectly

I encounter this problem when import simplejson. After a little search, I found that the problem is in the speedup extension, which its a binary module and has a manifest file but the version can not match the version under winsxs directory.

The python 2.7 need Visual Studio 9.0 to compile the simplejson speedup extension, if you don't have VC9.0, better just use the pure python version even you can compile it with another version of Visual C++.

The python 2.7 need Visual Studio 9.0 to compile the simplejson speedup extension, if you don't .

Python and Memcache Example

When I try to write some code in Python to access memcache service, I create a text file 'memcache.py'. This causes problems.

Only occurred in python script files, no problem with python shell. One of the reason may be the script file name is 'memcache.py'. Python will first try to load the module in the current directory,with that name, its importing itself. So the python script file name should be different from any module that imported in the script file.

Only occurred in python script files, no problem with python shell. One of the reason may be the script file name is 'memcache.py'. Python will first try to load the module in the current directory,with .

Crawl Google search results and open link in Chrome window with Python script

This script will record the search keywords and visited url into MySQL database .These data may be useful, its of interest to look back what you have been searched in Google.

The script also demonstrate how to access MySQL Server and crawl web pages with python.

Previous Page 1 ... 3 4 5 Next Page