Monday, September 14, 2009

sed to the rescue (python old-style classes are new again)

Python became my language of choice when new-style classes were still really new and not yet supported everywhere. Python seemed to work just fine and it was many years before I started using new-style classes.

So a lot of my code has: class English1A:

instead of: class English1A (object):

I finally got tired of having a mix of old and new classes and used sed to fix it:
sed -i .bak 's/^\(class .*[^()]\):/\1 (object):/' *py

No comments:

Post a Comment