[Tutor] MP3Info class usage

Kent Johnson kent37 at tds.net
Wed Dec 10 15:20:25 CET 2008


On Wed, Dec 10, 2008 at 7:48 AM, Gareth at Serif <gmorris at serif.com> wrote:

> Given that, for testing purposses, I have a property called 'testfile' set
> to the path of a valid MP3 file, I then try to output the artist name with
> the following, where ID3v2 is a class defined in MP3Info:
> song = ID3v2(testfile)
> print '\nArtist is: %s' % (song.artist)
>
> When I execute this script I get an error, "AttributeError: 'str' object has
> no attribute 'seek'".

The ID3v2 constructor wants a file object as a parameter, not a
string. It is trying to call testfile.seek() which causes the error
you see.

Try ID3v2(open(testfile))

Kent


More information about the Tutor mailing list