[Pypentago-devel] Code styleguide
Status: Pre-Alpha
Brought to you by:
segfaulthunter
From: Florian M. <flo...@ai...> - 2008-06-02 15:35:29
|
Hello. I have been thinking that maybe we should introduce a code style convention, so the source code is easier to read due to being uniform. On the other hand, it may be better if every one can use his own style so it is easier to develop for him. If we agree on making a convention, there are three proposals that are possible. One would be PEP8, the Python styleguide, compatibility and the other two would be adapting the style of the modules we are using, namely Twisted or wxPython. I think PEP8 has several advantages beside being the official Python style. The first is, because our external modules are *not* compatible to PEP8 we would never fall into naming issues overwriting their methods, of course this cannot be applied to class names, as they are the same in every of those three. The other would be that every Python developer should be able to read our code pretty well, as most of them have read the PEP8. Also I think the style is really clear and easy to read, but that is just my opinion. In this style, methods and functions have the same convention, but it is easy to tell from those two because methods have self as their first attribute. The Twisted style is the one I am using at the moment, because I somehow got used to it. There is not much difference between it and the PEP8, besides the convention for the method names. The advantage would be that the code looks uniform to the Twisted methods that we import, but then it does not fit the wxPython ones either. I personally like to name functions PEP8 style when using this, thus it is methodName but function_name, but this is subject to changes. Last and, for me, least the wxPython style. It is in fact C++ style as wxWidgets is C++ and wxPython is just a wrapper for it, thus not changing the naming convention. I like it least because with it it is hard to tell whether something is a class, method or function. It is actually pretty near to the Java style, something you might like. Just look at the code samples below to see which one you like best. If you do not like the idea of a code style convention, feel free to say that too. [1] PEP8: http://paste.pocoo.org/show/59160/ [2] Twisted: http://paste.pocoo.org/show/60063/ [3] wxPython: http://paste.pocoo.org/show/60064/ |