Archive for 'Python'

Reading a file into a Python string

I’ve learned a number of useful things from the Google learn Python video series. One of the tips I got to use today. That tip was Python’s ability to read a file into a string: $ cat foo this is a test file of words $ python >>> f = open(“foo”,”r”) >>> string = f.read() […]

Learn Python video series from Google

I’ve been trying to expand my Python knowledge and recently came across Nick Parlante’s 6-part learn Python series on Youtube. I’ve watched several of the videos, and I am impressed with Nick’s teaching ability. Here are links to the 6-part series: Day 1 part 1: Introduction and Strings Day 1 part 2: Lists, Sorting and […]

Serve out content over HTTP from your cwd immediatly

Ever want to immediatly serve content from a specific directory over HTTP, but didn’t want to bother messing with httpd.conf or other webserver configiurations? If you’ve got Python installed, this is a snap.  Execute python with the SimpleHTTPServer module, using port 8080 so there isn’t a need to elevate privs to root. $ python -m […]

Accessing the Python help facility from the Python shell

Python has a ton of useful modules, and the built-in help facility is extremely useful for gaining quick access to a description of methods in a given module. Once a module is imported with import: >>> import pexpect You can run dir(MODULE_NAME) to view the list of methods in the module: >>> dir(pexpect) [‘EOF’, ‘ExceptionPexpect’, […]

Installing Python modules with easy_install

I have been spending some of my spare time reading Learning Python, and experimenting with a number of Python modules. One of the cool things about the Python modules facility is easy_install, which allows you to install modules from local files or a remote location. To install a module from a local directory, you can […]

Awesome online Python resources

I have been spending a fair amount of time learning Python, and have come across a couple of cool online resources. If you are interested in learning Python but don’t want to buy a book, these (and lots of time writing code) resources are really all you need to become a Python guru: Python documentation: […]

« Older Entries