Python code is easily readable. But nothing is perfect and you can make even that code more clean. Here you can find my best two techniques for Python code. What about PEP8? I really don't find it useful...
My name is
Python has this special word - self - which is the reference to the object on which current method was invoked. It is not only useful but in most cases necessary to have it!
In most languages this word is a constant, like in C++ keyword this. But in Python it can be any arbitrary word, just need to be first on the method's parameters list. Despite that freedom in choosing name, everybody follows kind of standard using word self.
def method1( self , x, y ):
I don't think it is bad decision. Quite similar to this in length and meaning. But in Python it has to be typed more often than in C++. So why not to use shorter word? I want to propose new trend and use word me instead of self.
def method1( me , x, y ):It simply works for my projects better. Distinct in meaning and half shorter in length. Usage statistics of variables named me are quite small, so we can take it for that purpose.
Lets look at this code:
run(objX, param1, x, y)Typical function call. Now lets change formatting:
run( objX, param1, x, y )Change is small, somebody can say cosmetic, but readability is highly improved (in my opinion). Less time is needed looking for the first parameter.