Tuesday, September 23, 2008

Pygments

I thought I'd mention the Pythonic syntax highlighter Pygments. It is a very powerful syntax highlighter written in Python. It has a nice API that can be used from Python applications as well as a nice command line utility. Here is some sample output from the Pygments command line:

class MyClass:
"""This is my class."""
def __init__(self):
"""Constructor."""
self.my_attr=False

def set_my_attr(self, my_attr):
"""Set the my_attr attribute."""
self.my_attr=my_attr

def get_my_attr(self):
"""Return the my_attr attribute."""
return self.my_attr

if __name__=='__main__':
my_obj=MyClass()
my_obj.set_my_attr('Hello!')
print 'ATTR:', my_obj.get_my_attr()

This was actually printed to the console screen but can easily be captured in an HTML file.

No comments :

Post a Comment