Ian S. Yune

A little pause...a scarce moment of pause, which I feel is allowed to spend away with little hesitation and sore self-infliction, is the time while my coffee is being ready on the stove.

HTML Parsing

Reference

  • “HOWTO Fetch Internet Resources Using the Urllib Package” - file:///Library/Frameworks/Python.framework/Versions/3.2/Resources/English.lproj/Documentation/howto/urllib2.html?highlight=urlopen
  • “Python and HTML Processing” - http://www.boddie.org.uk/python/HTML.html (version 2.x)

Fetching URLs

import urllib.request

req = urllib.request.Request('http://www.voidspace.org.uk')
response = urllib.request.urlopen(req)
the_page = response.read()


Changing IDLE default path

/Applications/Python 3.x/IDLE.app/Contents/Resources

os.chdir(os.path.expanduser(‘~/Desktop/CWD’))

When this cause IDLE to crash with some idiotic message, this is because some file(s) in the folder you set as the default path, contains “import pickle”. Delete this file!

Python: Module Distribution & Importation

Definition

A module - ‘a text file that contains Python code’

Sequences

1. Don’t forget to comment the code: module comment & function comment on the function itself and the argument positions.

2. Create the Folder of <namespace>.

  1. Save the function as ‘sth.py’ in the namespace.
  2. Create ‘setup.py’