Peter Maas wrote:
Steven Bethard schrieb:
BJörn Lindqvist wrote:
[...]
I believe this can be nicelier written as:
if "Makefile" in basename:
+1 for "nicelier" as VOTW (Vocabulation of the week) =)
Me too, because nicelier is nicer than more nicely. :)
Is that really the niceliest way to express th
Steven Bethard schrieb:
BJörn Lindqvist wrote:
[...]
I believe this can be nicelier written as:
if "Makefile" in basename:
+1 for "nicelier" as VOTW (Vocabulation of the week) =)
Me too, because nicelier is nicer than more nicely. :)
--
--
BJörn Lindqvist wrote:
# do other non-extension-related tests here
if basename.find( "Makefile" ) != -1:
return "text/x-makefile"
I believe this can be nicelier written as:
if "Makefile" in basename:
+1 for "nicelier" as VOTW (Vocabulation of the week) =)
Steve
--
http://mail.python.o
> # do other non-extension-related tests here
> if basename.find( "Makefile" ) != -1:
> return "text/x-makefile"
I believe this can be nicelier written as:
if "Makefile" in basename:
--
mvh Björn
--
http://mail.python.org/mailman/listinfo/python-list
Stephen Thorne wrote:
As for the overall efficiency concerns, I feel that talking about any
of this is premature optimisation.
I disagree -- using REs is adding unnecessary complication and
dependency. Premature optimization is a matter of using a
conceptually more-complicated method when a sim
Despite the regexp alternatives, I refuse to post a pyparsing solution to
this! :)
-- Paul
--
http://mail.python.org/mailman/listinfo/python-list
Stephen Thorne <[EMAIL PROTECTED]> wrote:
> Why not use a regexp based approach.
Good idea... You could also use sre.Scanner which is supposed to be
fast like this...
import re, sre
scanner = sre.Scanner([
(r"\.php$", "application/x-php"),
(r"\.(cc|cpp)$", "text/x-c++-src"),
(r"\.x
On Thu, 13 Jan 2005 05:18:57 GMT, Bengt Richter <[EMAIL PROTECTED]> wrote:
> On Thu, 13 Jan 2005 12:19:06 +1000, Stephen Thorne <[EMAIL PROTECTED]> wrote:
>
> >On Thu, 13 Jan 2005 01:24:29 GMT, Bengt Richter <[EMAIL PROTECTED]> wrote:
> >> extensiondict = dict(
> >> php = 'application/
On Thu, 13 Jan 2005 12:19:06 +1000, Stephen Thorne <[EMAIL PROTECTED]> wrote:
>On Thu, 13 Jan 2005 01:24:29 GMT, Bengt Richter <[EMAIL PROTECTED]> wrote:
>> extensiondict = dict(
>> php = 'application/x-php',
>> cpp = 'text/x-c-src',
>> # etcetera
>> xsl = 'test
On Thu, 13 Jan 2005 01:24:29 GMT, Bengt Richter <[EMAIL PROTECTED]> wrote:
> extensiondict = dict(
> php = 'application/x-php',
> cpp = 'text/x-c-src',
> # etcetera
> xsl = 'test/xsl'
> )
>
> def detectMimeType(filename):
> extension = os.path.sp
On Wed, 12 Jan 2005 18:16:23 +, Frans Englich <[EMAIL PROTECTED]> wrote:
>
>As continuation to a previous thread, "PyChecker messages", I have a question
>regarding code refactoring which the following snippet leads to:
>
>> > runner.py:200: Function (detectMimeType) has too many returns (11)
Paul McGuire wrote:
"Frans Englich" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
#--
def detectMimeType( filename ):
extension = filename[-3:]
You might consider using os.path.splitext() here, instead of always
assuming
On Wednesday 12 January 2005 18:56, [EMAIL PROTECTED] wrote:
> I can not break the original code in 2.4, if I try this:
[...]
>
> So although the dictionary solution is much nicer nothing seems wrong
> with your code as it is - or am I missing something?
Nope, the current code works. I'm just lo
I can not break the original code in 2.4, if I try this:
import os, sys
class NoMimeError(Exception):
pass
def detectMimeType( filename ):
extension = filename[-3:]
basename = os.path.basename(filename)
if extension == "php":
return "application/x-php"
elif extension == "cpp" or extension.endswit
"Frans Englich" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> As continuation to a previous thread, "PyChecker messages", I have a
question
> regarding code refactoring which the following snippet leads to:
>
> > > runner.py:200: Function (detectMimeType) has too many returns (11)
As continuation to a previous thread, "PyChecker messages", I have a question
regarding code refactoring which the following snippet leads to:
> > runner.py:200: Function (detectMimeType) has too many returns (11)
> >
> > The function is simply a long "else-if" clause, branching out to
> > diffe
16 matches
Mail list logo