AnalogClock






Tuesday, February 12, 2013

Crushing Python

I've begun thinking in Python a lot lately. ~/.mypyrc.py:
# standard library
from collections import defaultdict as DD,namedtuple as NT
import csv
from datetime import date as D,datetime as DT,time as T,timedelta as TD
import operator as op
import os
import re
from cStringIO import StringIO as SIO
import sys
import time
from urlllib2 import build_opener as BO,install_opener as IO,Request as R,urlopen as UO
from urlparse import urljoin as UJ,urlparse as UP
from zipfile import ZipFile as ZF
# third party libraries
from BeautifulSoup import BeautifulSoup as BS,BeautifulStoneSoup as BSS
import pytz
# initialization
IO(BO())
~/.profile or ~/.bash_profile:
PYTHONSTARTUP=~/.mypyrc.py
export PYTHONSTARTUP
Now starting python interactively loads the PYTHONSTARTUP file automagically:
python
>>> for f in ZF('a.zip').namelist:
...  print f
... 
>>> print BS(UO(R('http://google.com'))).find('title').text
>>> cols=zip(*csv.reader(open('a.csv')))
>>> rows=zip(*cols)

pypad - the python notepad web server

The plan is to take this simple python script and expand on it's note taking features with a GUI, console, and command line front end and additional storage options including a tiddlywiki style of appending the data store to the script.

The web server will eventually be an option rather than integral.

http://launchpad.net/pypad

I will fork this into a micro framework and also fork it into a python eval type remote or local shell. Maybe even a REPL embedded in a web page.