June 4, 2006 will

Python Netstring Module

Netstring.py’ is a Python module to encode / decode netstrings. A netstring is a simple protocol for encoding arbitrary strings in a file or datastream. They have the major advantage over the traditional zero terminated strings in that the reader knows the size of the string up front and does not have to examine the data a byte at the time.

There is no documentation for this module other than the docstrings, but hopefuly that should cover it. For more information on the netstring protocol see the official netstring protocol document.

Use Markdown for formatting
*Italic* **Bold** `inline code` Links to [Google](http://www.google.com) > This is a quote > ```python import this ```
your comment will be previewed here
Louis Cordier

How does it differ from say, ftp://ftp.dlitz.net/pub/dlitz/python/netstring/netstring.py
which is at version 1.1 and has been around since 2003 ?


There's not a great deal of difference in functionality. Although my version works slightly differently in that the client gives data to the reader object, rather than the reader requesting it through a file-like object.

I think my version is also stricter. The dlitz version permits leading zeros in the size field as far as I could tell, and allows strings of 10**1000 - 1 bytes long! The intended use for my netstring.py was for network protocols, so the strictness was a consideration.


Does this code have any licence? The way it is distributed now is equivalent to "all rights reserved, never use it anywhere".


See a more recent blogpost regarding netstring...