Style conventions when extending a third-party class

A forum for general discussion of the Python programming language.

Style conventions when extending a third-party class

Postby gratuitous_arp » Sun May 19, 2013 3:38 pm

Hi all,

I would like to see what the forum thinks about style conventions when extending a third-party class inside a separate project. Take this scenario: Suppose that you are working on a project that uses joined_lowercase method names, but you need to extend a third-party library that uses camelCase method names. You don't intend to contribute your subclass to the originating project, so you are not bound to the base class project's code style.

What style convention would you use in your derived class? Would you keep it consistent with the base class (camelCase), or keep it consistent with the rest of your project (joined_lowercase)? Would you only use camelCase in places where you override the base class's methods, and joined_lowercase for everything else?

Since it will come up sooner rather than later, PEP8 says this regarding style-clashing in function names:

Function Names

Function names should be lowercase, with words separated by underscores as necessary to improve readability.

mixedCase is allowed only in contexts where that's already the prevailing style (e.g. threading.py), to retain backwards compatibility.
gratuitous_arp
 
Posts: 6
Joined: Tue Apr 16, 2013 11:10 pm

Return to General Discussions

Who is online

Users browsing this forum: Bing [Bot] and 3 guests