integer woes...

Luke McCarthy luke at ukonline.co.uk
Tue Feb 18 21:50:08 EST 2003


I have written an ID3v1 MP3 tag reader, but I have one slight problem. The
track number is a two-byte integer and reads into Python like so:

>>> tag.track
'\x00\x17'

(in this example, the track number is 23, which is hex 17)

My dilemma: how can I convert this into an integer?

int(tag.track) doesn't work!
I get: ValueError: invalid literal for int():

Whoever designed these tags must be weird. Why was the track number a short
int yet the year a string??? Why make artist, title and album 30 chars long
yet make the comment 28 chars long???

Luke McCarthy






More information about the Python-list mailing list