[Tutor] Newbie append puzzle
Tim Ronning
tim.ronning at start.no
Mon Nov 3 06:48:06 EST 2003
På Sun, 2 Nov 2003 12:55:00 -0800 (PST), skrev Daniel Ehrenberg
<littledanehren at yahoo.com>:
>> else:
>> sys.exit()
>>
>> - - - - -END CODE - - - - -
>>
>> Best regards
>
> Your program uses the string module, which is
> obsolete. Most of the string methods have been
> replaced with methods on the string type, acting as an
> object. Here's the part where you used the string
> module:
>
>> def makeaList(s):
>> anothermp3 = string.split(s)
>> return anothermp3
>
> Using the builtin string methods, you would instead
> write:
>
>> def makeaList(s):
>> anothermp3 = s.split()
>> return anothermp3
>
> but I would probably impliment it like this:
>
>> makeaList = lambda s: s.split()
>
> and I'd define it outside of the while loop. If you
> define it inside of the loop, it is defined over and
> over again, slowing the program.
>
> I don't think the filenames you used will work as you
> intended. When you were making a new playlist, you
> opened the file playlist.new (playlist is the name and
> new is the file extention, not a new playlist). When
> you're reading the playlist, you open a file named
> playlist with no file extention. These files are in
> the directory where the script is run. If you open a
> file that doesn't exist, the file is automatically
> created. I would open something like playlist.dsp
> whether or not the playlist exists.
>
> What are the ao and mad modules that you're using?
> They're not builtin so I can't use your mp3 player.
> Where could I find those modules?
>
> Daniel Ehrenberg
Thanks for valuable input Danliel. Didn't know that the string module was
obsolete. I only have an older book on Python so this kind of input is gold
for me. I'm planning on getting "Learning Python 2.ed." from O'Reilly when
it hits the market sometimes in december.
I'm using the libMad mp3 decoder for this player. It uses a bit more
resources but it produces a cleaner sound than the mpeg123 decoder.
Here are the links:
libMad decoder: http://www.underbit.com/products/mad/
pyMad wrapper module: http://spacepants.org/src/pymad/
ao module: http://www.andrewchatham.com/pyogg/
Best regards
Tim Ronning
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
More information about the Tutor
mailing list