[Tutor] Instantiating a list of strings into a list of classes

Daryl V vandyke.geospatial at gmail.com
Sat Mar 6 02:38:08 CET 2010

Hello All-

I cut my teeth of Fortran95, and in the distant past rode the turtle, and
while I enjoy the mind-bendy feeling of shifting my programming paradigm
(and LOVE LOVE LOVE Python), I get sheepish when I feel I'm missing
something basic.

I have a csv list of data, of the form:
plot, utmN83_X, utmN83_Y, plot_radius_m

I built a nifty ClassGPSPoint(Xpos,Ypos,plotRadius,workPaths) that eats the
X&Y positions, the plot radius, and previously instantiated object holding
all of the appropriate paths definitions to access the LiDAR LAS files.

I make a nice CSV reader with one line (did I mention I LOVE python?)...

plotReader =

What I want to do is use the first entry in that row (row[0]) as the
variable name for the instantiated class.  I'd get an instantiated GPSPoint
object called 'Spring1' that would yield all my methods and defined values
(Spring1.pathLASfile, Spring1.perturbXY(), etc)....
Hence, in pseudocode:

for row in plotReader:
   row[0] = GPSPoint(row[1],row[2],18.3,workPaths)

But that doesn't work.  I'm probably missing something basic and profound,
(I was trying to use global to track my paths until I got my mind around the
passing the instantiated object thing, but whaddya gonna do?  Sequential to
OO is a big shift, you know?)

Thanks ya'll -

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100305/8a74a8d1/attachment-0001.html>

More information about the Tutor mailing list