Underscore/Camelcase insensitivity

Martijn Faassen m.faassen at vet.uu.nl
Sat Feb 22 10:48:52 CET 2003


Hi there,

I present to you all PEP 3008: Underscore/Camelcase insensitivity. Guido
is entirely tired of this debate and asked me to make a posting about it
here so that comp.lang.python can decide.

Many people use camelCase for method names, others use under_scores. Some
people like myself find ourselves switching between the two, not
knowing which to prefer. Plus, beginners can forget to spell it under_score
and accidentally use camelCase and vice versa, which is not a good thing.

Guido is asking you all to discuss this proposal, come up with other
proposals and a voting procedure, and then the voting result. 

The following proposal is made:

  def foo_bar_baz():
      pass

can be called like this:

  foo_bar_baz()

but under the new PEP 3008 rules, also like this:

  fooBarBaz()

And likewise, the following definition:

  def fooBarBaz():
      pass

can be called also using its underscore equivalent:

  foo_bar_baz()

Of course this also works for attributes:

  getattr(foo, 'foo_bar_baz')

  getattr(foo, 'fooBarBaz')

will do exactly the same thing.
 
Functions and methods which would have the same name under the new rule 
simply have the last definition win; it is not expected there are many
instances of this case but Python will issue a CamelUnderscoreWarning if
they are encountered.

Regards,

Martijn
-- 
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?




More information about the Python-list mailing list