Underscore/Camelcase insensitivity

Alex Martelli aleax at aleax.it
Tue Feb 25 03:48:37 EST 2003


Alexander Schmolck wrote:

> m.faassen at vet.uu.nl (Martijn Faassen) writes:
>> the camelCase convention. This week I was pondering making a mixin class
>> which helps us transition underscore to camelcase automatically. So, in a
>> way I was even serious here.
> 
> I've actually discovered that converting from and to camelCase is really
> much more of a pain than you'd think (I might just be doing it stupidly).

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66009

I think I have a better solution in the way I expanded this recipe
in the printed Cookbook (seeing a mixedcase or underscored name as
a hidden sequence of underlying words, recovering the words, and
joining them up again by whatever convention is required).

But both approaches break horribly for e.g HTTPBaseHandler, finding
it hard to gauge which of the caps are "breaks" in the word sequence
and which are not.  Not impossible, I guess, just hard;-).


Alex





More information about the Python-list mailing list