parallel port?!?

Peter Hansen peter at
Sat Jul 14 12:43:16 EDT 2001

Richard B wrote:
> I would like to know how to communicate with the parallel port under
> python. Is this possible? If so can it be done under all operating
> systems that support python.

No.  There is no such thing as a truly cross-platform parallel port
solution, much as there is no cross-platform serial port support.

> I need to interface with the parallel port to send commands to a board
> connected to it. I have just come to grips with python, it is my first
> language, so I think this is what I should use to communicate with the
> parallel port so that I can implement new features latter on. 

You might consider reducing the scope of what you are trying to do,
or at least breaking it into phases.  You are apparently in the difficult
position of:

 1. Being new to programming, in general.
 2. Being new to Python.
 3. Needing a cross-platform solution (do you really?).
 4. Needing a solution, bad ("this is kind of important")
 5. Not having access to other resources nearby to help.

You have at least one thing in your favour: your fine taste in 
a first language to learn. :)

Python is definitely capable of doing this, but I suggest you
learn to walk before you run.  In this case, start by walking 
through the Python tutorial, if you haven't already.  

Also spend some time clarifying your specific requirements.  
Parallel port communication can take many forms.  For one thing,
are you trying to control individual data pins directly?  Do
you need handshaking?  Are you trying to stream data through
the port the way you might with, say, a parallel port tape drive?
Do you need bidirectional communications?  EPP or ECP?  Special
timing considerations?  The latter thing might be something
which actually *prevents* you from using Python, as it might
not be high-performance enough to provide you with the necessary
signal timing.

I'm guessing you need to be able to set up the data pins as
outputs, then place a particular bit pattern on them, then
toggle a handshaking line active then inactive.  If this is
the case, what you could do under DOS would probably be suitable
here.  That means finding a way of talking directly to the 
control registers of the parallel port, at 0x378 for LPT1
for example. 

A quick search on didn't produce any useful
results for me, so my only other suggestion at the moment 
is to look into the win32all extensions produced
by Mark Hammond and available by following the links at .  These provide direct access
to the Win32 API which doubtless has some routines that
could provide direct access.  

I know this is probably not a big help at the moment, 
and if I'd done this myself I'd send you something 
more useful.  I've generally tried to avoid using the 
parallel port to communicate with things because it 
is generally unreliable and complicated to use 
compared to a serial port... And I know *that* doesn't 
help when you don't have control over the nature
of the other device...

Peter Hansen, P.Eng.
peter at

More information about the Python-list mailing list