Patrick Down wrote:
> What about:
>
> if True in [thefile.endswith(x) for x in
> ('mp3','mp4','ogg','aac','wma')]:
That will catch (widely used) file names such as 'tmp3' or
'i_cant_spell_frogg'. ;)
--
http://mail.python.org/mailman/listinfo/python-list
What about:
if True in [thefile.endswith(x) for x in
('mp3','mp4','ogg','aac','wma')]:
--
http://mail.python.org/mailman/listinfo/python-list
Steven Bethard wrote:
> bruno modulix wrote:
(snip)
>> ext = os.path.splitext(filename)
>
> Check the docs[1]. This should probably read:
> _, ext = os.path.splitext(filename)
Of course. Au temps pour moi.
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p
On Sun, 05 Jun 2005 13:52:09 -0400, Roy Smith wrote:
> One sure sign of somebody trying to write C in Python is when they loop
> over a list by doing
>
> for i in range (len (myList)):
>doSomethingWith (myList[i])
I usually do that, and I've never coded a line of C in my life. I can't
even
bruno modulix wrote:
> Here's a somewhat more pythonic version:
>
> filelist = os.listdir(path)
> for filename in filelist:
> # I assume you want to remember what's the ext is
> ext = os.path.splitext(filename)
Check the docs[1]. This should probably read:
_, ext = os.path.splitext
Ognjen Bezanov wrote:
(snip)
> filelist = os.listdir('/mnt/cdrom/') #get a list of files from the cdrom
> drive
Please put long comments on the previous line... And BTW, please avoid
useless comments that just paraphrase the code
> for thefile in filelist[:]: #for each file in the fi
venkata subramanian <[EMAIL PROTECTED]> wrote:
> It just reminds me that the most important thing about learning a
> language is also to learn its style and "paradigm" and not just its
> syntax and semantics. Or one might end up wrenching in
> "C-like-thinking" into a python program where it might
I'm sorry if this mail (also) sidetracks the primary theme of this
thread. But, it was a moment of "shock and awe" seeing the use of list
for checking among multiple options ... which is usually done using a
name=opt1 or name=op2 etc.,
I started as a C programmer and hence, that style of thinkin
Robert Kern wrote:
> Ognjen Bezanov wrote:
>
>> Robert Kern wrote:
>>
>>
>>> Ognjen Bezanov wrote:
>>>
>>>
Another newbie-ish question.
I want to create an if statement which will check if a particular
variable matches one of the statements, and willl execute the
statement
Ognjen Bezanov wrote:
> ext = thefile.split('.') #get the file extension
> ext[1] = ext[1].lower() #convert to lowercase
As a side note, ext[1] will be the first extension:
>>> 'foo.bar.ogg'.split('.')[1]
'bar'
I'd advise ext[-1], the last element of the spli
Ognjen Bezanov <[EMAIL PROTECTED]> wrote in
news:[EMAIL PROTECTED]:
> Robert Kern wrote:
>
>> Ognjen Bezanov wrote:
>>
>>> Another newbie-ish question.
>>>
>>> I want to create an if statement which will check if a
>>> particular variable matches one of the statements, and willl
>>> execute the
Ognjen Bezanov wrote:
> Robert Kern wrote:
>
>
>>Ognjen Bezanov wrote:
>>
>>
>>>Another newbie-ish question.
>>>
>>>I want to create an if statement which will check if a particular
>>>variable matches one of the statements, and willl execute the statement
>>>if the variable matches any of the st
Robert Kern wrote:
> Ognjen Bezanov wrote:
>
>> Another newbie-ish question.
>>
>> I want to create an if statement which will check if a particular
>> variable matches one of the statements, and willl execute the statement
>> if the variable matches any of the statements.
>>
>> I have tried the f
Ognjen Bezanov wrote:
> Another newbie-ish question.
>
> I want to create an if statement which will check if a particular
> variable matches one of the statements, and willl execute the statement
> if the variable matches any of the statements.
>
> I have tried the following (the pass is just us
14 matches
Mail list logo