Archive for category Python

Python: Use Epydoc to generate javaDoc like documentation for Python

As I have already mentioned in Python: Use the pydoc.py module for documentation, documentation is an important aspect.
Now, the docs generated by pydoc aren`t looking too fancy. Today I`ll explain how to generate docs that look a bit more like documentation generated by javaDoc in a step by step tutorial.
Requirements:

Download Graphviz
Download Epydoc

Graphviz is needed to [...]

Tags: , , , ,

Python: Parse IIS 6.0 W3C Extended Log Files using Python and YUI libraries

I wrote a tool that parses my logfiles generated by Microsoft Internet Information Services 6.0. On top of that I added functionality to create standard HTML or YUI powered HTML files. This means that all the information in the logfiles will be displayed in an HTML table. The tool supports single logfile processing as well [...]

Tags: , , , ,

Full qualified domain name and Whois lookup using Python

I am working on a parser that parses my logfiles at the moment. Since I extract all ip addresses from the logfiles I was interested in doing an automated Whois look up against those.
Python`s socket module has some interesting methods that I used to resolve this problem:
socket.gethostbyaddr(ip_address)
Return a triple (hostname, aliaslist, ipaddrlist) where hostname is [...]

Tags: , , , , , ,

Python, Django: invalid literal for int with base 10

I get quite some traffic for the term “invalid literal for int with base 10″. I guess a lot people fumbling around with Python or Django are getting this error message once in a while. This happens when you try to cast a string into an integer and this string does not really contain a [...]

Python, Django Framework: Easily add your models to the django admin interface

Django comes with an admin interface which lets you easily add content to your Django powered website. In this post I will give you an easy example on how to plug your models into the admin interface. I asume that you already have setup a new Django project.
1. First add ‘django.contrib.admin’ to the installed apps [...]

Tags: , , , , , , , , ,

Python Logging: Use the logging module to generate debug information

Debugging your source code or application is a very important aspect. Python comes with a logging module, which is pretty much similar to log4j. I wrote a method in Python that lets you customize some aspects of the logger, for example where to output your logging information.

def createLogger(file=None, logger_name=None, format=False, log_to_console=False, get_hdlr=False):
[...]

Tags: , , , , , , , , , ,

Python: Use the pydoc.py module for documentation

As I am working with Python for a bit now I was looking for a documentation tool. Something similar to JavaDoc. I found out that there is Pydoc for Python and here is how you can use it:
For a description switch to your ../Python/Lib folder and execute pydoc.py, see the screenshot below.

Oh nice, a built [...]

Tags: , , , ,