VT100 in Python

bouncyinc at gmail.com bouncyinc at gmail.com
Tue Sep 15 04:58:59 CEST 2009

I hate to ask but what kind of "device".....and what`s with all the `insult` strings? - gimmick?

------Original Message------
From: <exarkun at twistedmatrix.com>
To: <python-list at python.org>
Date: Mon, 14 Sep 2009 01:43:11 PM +0000
Subject: Re: VT100 in Python

On 09:29 am, nick at craig-wood.com wrote:
>Wolfgang Rohdewald <wolfgang at rohdewald.de> wrote:
>>  On Sunday 13 September 2009, Nadav Chernin wrote:
>> > I'm writing program that read data from some instrument trough
>> >  RS232. This instrument send data in VT100 format. I need only to
>> >  extract the text without all other characters that describe how to
>> >  represent data on the screen. Is there some library in python for
>> >  converting VT100 strings?
>>  that should be easy using regular expressions
>At a basic level parsing VT100 is quite easy, so you can get rid of
>the VT100 control.  They start with ESC, have other characters in the
>middle then end with a letter (upper or lowercase), so a regexp will
>make short work of them.  Something like r"\x1B[^A-Za-z]*[A-Za-z]"
>You might need to parse the VT100 stream as VT100 builds up a screen
>buffer though and the commands don't always come out in the order you
>might expect.
>I think twisted has VT100 emulator, but I couldn't find it in a brief
>search just now.

Yep, though it's one of the parts of Twisted that only has API 
documentation and a few examples, no expository prose-style docs.  If 
you're feeling brave, though:



  http://twistedmatrix.com/projects/conch/documentation/examples/ (the 
insults section)

It's not really all that complicated, but without adequate docs it can 
still be tricky to figure things out.  There's almost always someone on 
IRC (#twisted on freenode) to offer real-time help, though.


More information about the Python-list mailing list