Mike takes to heart the adage that ideas are f***ing worthless without action.

Friday, July 24, 2009

Shaking off the cobwebs, getting back into it

I've got some programming ideas, inspired by previous efforts and the most recent lessons learned from Google Wave, I'm going to start a python project to handle translating source code (specifically pascal code) bidirectionally to object code and symbol tables.

My main programming exerience is in Borland's Delphi 5, which suceeded a number of years using Turbo Pascal 7.0 under DOS. So, these new languages like Python, etc al. are a bit odd to me, but I really like the power of the built in dictionaries, tuples, etc.

I'm using an old build of Active State python (2.5.1) which I'll be updating. I managed to write a few modules with very trivial amounts of code, cribbing heavily from "Dive into Python" by Mark Pilgrim.

Here it is... ALL of it...


"""Translates internal representation to and from xhtml"""

#define Exceptions

class HtmlError(Exception): pass
class invalidHtmlError(HtmlError): pass

def toHtml(x):
"""convert x to html string"""
return x

def fromHtml(x):
"""convert html string to internal representation"""
return x


"""Unit test for translate01.py"""

import translate01
import unittest

class KnownValues(unittest.TestCase):
knownValues = ( ( '', ''),
( 'x','x'))
def testToHtmlKnownValues(self):
"""ToHtml should give known results with known input"""
for s1,s2 in self.knownValues:
result = translate01.toHtml(s1)
def testFromHtmlKnownValues(self):
"""FromHtml should give known results with known input"""
for s1,s2 in self.knownValues:
result = translate01.fromHtml(s2)

if __name__ == "__main__":

It actually runs.... and tests ok... (because it's trivial right now)

PythonWin 2.5.1 (r251:54863, May 1 2007, 17:47:05) [MSC v.1310 32 bit (Intel)] on win32.
Portions Copyright 1994-2006 Mark Hammond - see 'Help/About PythonWin' for further copyright information.
>>> ..
Ran 2 tests in 0.000s


So.... I'm on a journey... and I just took the very first step... a thousand miles to go. ;-)

No comments:

About Me

My photo
Munster, Indiana, United States
I fix things, I take pictures, I write, and marvel at the joy of life. I'm trying to leave the world in better condition than when I found it.