[Tutor] question on self
Bill Allen
wallenpb at gmail.com
Tue Mar 13 11:51:08 CET 2012
This little thread on the usage of self references when calling class instance methods and attributes was excellent, one of the best I have seen.
Thanks,
Bill Allen
Sent from my iPhone
On Mar 12, 2012, at 3:56, Alan Gauld <alan.gauld at btinternet.com> wrote:
> 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/
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list