Hair cut
25 Aug 2003Before I headed off to NYC on Tuesday Laura and I got hair cuts. Mine was pretty drastic.


Before I headed off to NYC on Tuesday Laura and I got hair cuts. Mine was pretty drastic.


An example of how to add a method to a class, and how to add to just an instance of object.
import new
# add method to all object of a class
class test:
pass
def monkey(self):
print "eek"
tta = test()
ttb = test()
tta.__class__.monkey = monkey
print "%r" % tta.monkey
print "%r" % ttb.monkey
# add to one instance
class test2:
pass
tt2a = test2()
tt2b = test2()
tt2a.monkey = new.instancemethod(monkey, tt2a, tt2a.__class__)
print "%r" % tt2a.monkey
# this will cause an exception
print "%r" % tt2b.monkey
Test versus Type. More reason why I wish we used only python at work.
One idea I got from this is writing unit tests for java code in jython. At work we have a large java application, no unit test yet, perhaps jython could be employed here.
Python & Java: a Side-by-Side Comparison. Wish we were an all python shop at work.