1 An example

Let's go in medias res and have a look at a simple example:

from visa import *

my_instrument = instrument("GPIB::14")
my_instrument.write("*IDN?")
print my_instrument.read()
This example already shows the two main design goals of PyVISA: preferring simplicity over generality, and doing it the object-oriented way.

Every instrument is represented in the source by an object instance. In this case, I have a GPIB instrument with instrument number 14, so I create the instance (i.e. variable) called my_instrument accordingly:

my_instrument = instrument("GPIB::14")
 "GPIB::14" is the instrument's resource name. See section 1.3 for a short explanation of that.

Then, I send the message ``*IDN?'' to the device, which is the standard GPIB message for ``what are you?'' or - in some cases - ``what's on your display at the moment?'':

my_instrument.write("*IDN?")
Finally, I print the instrument's answer on the screen:
print my_instrument.read()


Subsections