Passing parameters (via tags)

This may be more of a general Python question.

I have a function that reads a file and does some processing on values. I then need to pass these values back to the calling functions .

I thought I’d just use tags and just return an object with all the tags to the calling function.

something like:
charData.name = csvRecord[0]
charData.mesh = csvRecord[1]
etc.

and then return charData

my question is how do i instantiate the object charData so i can attach tags. Also, if I should use a Panda object for this purpose (thought that would be waste as it’s only for param passing)

i dont exactly get what you are intending to do. but to me it sounds like python dictionaries are something that might be of interest to you.

Data-only objects are a peculiar case of object design. Python 2.6 has the named-tuple type, or you could just use a blank instance of a blank class:

class BlankClass: pass

or

BlankClass = type( 'BlankClass', ( ), { } )

The blank objects are the same as a dictionary, though.

obj[ 'attrib' ]

vs.

obj.attrib

and possibly more reliable using constants:

obj[ ATTRIB_STR ]

You could use ‘ctypes’ if you want to get exotic, or say a ‘numpy’ array or something. And ‘slots’ may give you the right feel in a class that you have blank otherwise.

Thanks! the blank class was exactly what I was thinking of. (just didnt know the syntax)

I added the 1 line to my code and it all works.

So versatile, yet straight-forward. I have many times lobbied to get it into the Python standard library.