9.2. Creating an athenaCL Interpreter within Python

Within a Python interpreter or a Python script on any platform, one or more instances of the athenaCL Interpreter can be created and programmatically controlled. The cmd() method of an Interpreter instance allows athenaCL commands and arguments to be passed to the Interpreter as strings. The cmd() method returns two values, a status flag (0 or 1) and a string message or display. The status flag must be checked to determine successful completion of a command; as the Interpreter is designed to handle errors, exceptions generally will not be raised.

Example 9-3. An athenaCL Interpreter in Python

>>> from athenaCL import athenaObj
>>> athInptr = athenaObj.Interpreter()
>>> ok, msg = athInptr.cmd('AUpc 9000hz')
>>> if ok: print msg
...
AthenaUtility Pitch Converter
format              fq        
name                C#~9      
midi                121       
pitch-class         1         
pch                 13.0125   
frequency           9000.0000 
pitch-space         61.25