Python commands

Thomas Heller theller at
Thu Apr 3 08:43:22 CEST 2003

"Paul Dexter" <dextech at> writes:

>     Hi all,
>                 I have just discovered Python and I was wondering if anyone
> could help me find an equivalent command in Python for the "OUT" and "INP"
> commands in Qbasic. I wish to convert a Qbasic program to Python.
>     The following snippet is an example of the task I wish to perform;
> base0 = &H378:
> interface:
> OUT base0, &HA0
> OUT base0, &H80
> OUT base0 + 2, &H8
> V = (INP(base0 + 1) AND &H10) * &H8
>     The base address is 378 (lpt) and the "interface" subroutine outputs
> data to the port (378) and "V" is the input data statement I have used. I
> also use the "GETKEY", "LOCATE" and "DRAW" commands in Qbasic
>     Does anyone know how to perform the same tasks/commands in Python or are
> they even available. I have come across other Basic computer language
> variations that do not support the commands I require.
>     Thankyou for any help,
>                                         Paul

Usually port I/O instructions cannot be used from user mode programs,
even on Windows (NT, 2000, XP). This may be different on win95 or win98.

However, the ctypes module allows calling functions in dlls, and this
is what I get on WindowsXP (windll.msvcrt loads the MS C runtime
library, and _outp is the function):

>>> from ctypes import windll
>>> windll.msvcrt._outp(0x378, 0xA0)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
WindowsError: exception: priviledged instruction


More information about the Python-list mailing list