Underscore/Camelcase insensitivity

Alexander Schmolck a.schmolck at gmx.net
Tue Feb 25 19:20:35 EST 2003


m.faassen at vet.uu.nl (Martijn Faassen) writes:

> Yes, now the problem intrigues me, so could you mail them to me?

Sure.

> 
> > But If you can come up with something readable that still
> > 
> > 1) splits correctly
> > 2) preserves all case information that is not used for boundary demarcation
> > 3) moans about illegal input (but not about leading and trailing underbars)
> > 
> > that would be even better (and the test examples might help).
> 
> Except that even if more readable it might be still significantly slower. 

Well, I'm pretty sure that my version could be improved in both performance
and readability. At least I hope it works properly.

> Anyway I agree that the problem is surprisingly complicated if you put
> these requirements on it.

Yep, which is the main reason why this code is so contorted. Underestimating a
task like this can easily result in the mallet approach to software
engineering (bang it till it works). All the more when simple parsing is
involved, since python's sluggishness unfortunately tempts one into using
regexps (which might suck not quite as badly if `sre` would at least allow you
to convert to/from some manipulatable AST representation).

alex


Some people, when confronted with a problem, think ``I know, I'll use regular
expressions.'' Now they have two problems. 

-- jwz




More information about the Python-list mailing list