> My first stumbling block is that M4A files store the track number and
> track total in a single tuple ... but I need them as separate fields
> one of many hurdles -- I need a way to accomplish more than a
> one-to-one data map.

In that case map to a function which can return the value.
Use lambdas for the trivial cases:

'Title': lambda : fileData['title']

For 1-1 maps:

'Artist' : lambda : fileData['ART']

For more complex maps:

'Track' : lambda : flieData['TRK'][0]
'Total' : lambda : fileData['TRK'][1]

And for more complex things define a function:

def complexMap(key):
      # do something here
      return result

'WeirdThing' : lambda : complex ('WeirdThing')


Then just call the funcyion when needed:

myDatya = map[key]()   # parens calls the function

> having trouble.  I feel there may be a way to pass functions through
> my tag_map dictionary (maybe a lambda?!) but I can't get my head
> around what approach is best 

Does what I've shown make sense?


 Alan Gauld
Author of the Learn To Program website
http://www.alan-g.me.uk/



________________________________
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to