[Tutor] XMMS song search

R. Alan Monroe amonroe at columbus.rr.com
Sun Aug 7 17:46:04 CEST 2005

> songsearch = raw_input(Enter song name: ")
> f = file(/home/joe/.xmms/xmms.pls)

Don't forget your quotation marks around the filename.

> f.find(songsearch)

You _find_ stuff in strings, not in the file itself. Read each line of
the file one at a time, because each line will be a string.

for thisline in f:
    if thisline.find(songsearch) > 0:
       print thisline

#Also at the end of the program don't forget to close what you opened


More information about the Tutor mailing list