Anything similar to definition file?

Quinn Dunkan quinn at hork.ugcs.caltech.edu
Thu Jan 17 13:53:29 EST 2002


On 16 Jan 2002 18:23:21 -0800, Ozone Hole near South Pole
<ozonehole2k at yahoo.com> wrote:
>Hi,
>
>I am writing a robot controlling script in python.  The status info of
>the robot is stored as in a list: [ [rec1], [rec2],.... [recN] ]
>In each rec, rec= [ sampleID, pos_x, pos_y, pos_z, force_r, force_t,
>....]
>
>As the program is reasonable large, the algorithms are broken into a
>number of files. To make the code a bit easy to read, I would like to
>refer say, the y-pos at the 2033 rec as rec[2033][pos_y], rather than
>rec[2033][2] #pos_y.
>
>At this moment, I need to include the following header to each file:
>#record fields
>sampleID,pos_x,pos_y ...=0,1,2 .......
>
>Does python have anything similar to a header file in C such that I
>can do,
>say, import myConfig, in each my file instead of repeating the above n
>times?

If you want to make a bunch of constants available:

-- file constants.py ---

sampleID, pos_x, pos_y, etc = range(4)

-- every where else ---
from constants import *

---

You might want to consider writing your own classes for the data instead of
reusing lists.  Then you would write 'rec[2033].pos_y'.



More information about the Python-list mailing list