[Tutor] lists

Norman Khine norman at khine.net
Tue Jan 20 19:02:57 CET 2009


Hi,
actually what I was trying to do carries from my last post, where my 
media files are a list that I want to add to the

subprocess.call(['sox', ', '.join(media_list), 'list.wav'])

 >>> print ', '.join(media_list)
upper_b.wav, upper_a.wav
 >>> subprocess.call(['sox', ', '.join(media_list), 'list.wav'])
sox formats: can't open input file `upper_b.wav, upper_a.wav': No such 
file or directory
2
 >>>

but this is treated as one item, rather than the two.



Kent Johnson wrote:
> On Tue, Jan 20, 2009 at 11:30 AM, Norman Khine <norman at khine.net> wrote:
>> Hi
>> What am I doing wrong
>>
>>>>> media_list = ['upper_b.wav', 'upper_a.wav']
>>>>> print '%s' % (for x in media_list)
>>  File "<stdin>", line 1
>>    print '%s' % (for x in media_list)
>>                    ^
>> SyntaxError: invalid syntax
>>>>> print '%s' % (x for x in media_list)
>> <generator object at 0x532210>
>>
>> I want to replace %s with the items of the list as individual item string,
>> i.e
>>
>> 'upper_b.wav', 'upper_a.wav'
> 
> I'm not sure what you want, maybe one of these?
> 
> In [1]: media_list = ['upper_b.wav', 'upper_a.wav']
> 
> In [2]: print ', '.join(media_list)
> upper_b.wav, upper_a.wav
> 
> In [3]: print ', '.join(repr(x) for x in media_list)
> 'upper_b.wav', 'upper_a.wav'
> 
> Kent
> 


More information about the Tutor mailing list