[Tutor] question on self

Alan Gauld alan.gauld at btinternet.com
Mon Mar 12 09:56:16 CET 2012


On 12/03/12 02:02, Michael Lewis wrote:

> I have another method called take turns (not shown for brevity
> purposes). When I want to call it, why can't I just call it like a
> function and use TakeTurns() instead of self.TakeTurns()?

The Steve's have given technical answers, its also stylistically
better because it removed ambiguity for the reader as well as
for Python.

Many corporate style guides advocate using this same style
when using C++ or Java to make it explicit when you are using
a class attribute rather than a local or global value/function.

It improves code clarity and therefore reduces potential bugs
and speeds up maintenance for a tiny loss in initial coding
productivity.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list