I want to create a function or a class method that will create a dictionary named by a variable that is passed in.
By way of example, I'm creating a class method to read data from a table (in this case it's an ArcGIS table, but that's not critical) and I'd like the method to give me a dictionary identified by the string stored in OutputDictionaryName (see below).
class ReadTableIntoDictionary():
def __init__(self, TableSource, KeyField, OutputDictionaryName):
self.TableSource = TableSource
self.KeyField=KeyField
self.DictName = OutputDictionaryName
(rest of code goes here to extract the data from the table into a dictionary ... no problem, I can do that part)
But how do I create a dictionary called by the name in OutputDictionaryName?
For example I'd like to call
ReadTableToDictionary(PointCoordinateTable, PointID, PointCoordinateDict)
and get back a dictionary
PointCoordinateDict(k,v) that I can use
then I'd like to use the same method to read another table into a dictionary, eg
ReadTableToDictionary(DatumTable, DatumID, DatumDict)
I have several tables of data to read in and I'd like to just call this method for each table rather than having to write the same code over and over.
Seems simple, and it's probably easy, but it's Friday afternoon and I'm stumped.
Thanks