Re: [Tutor] question on self

2012-03-13 Thread wesley chun
i want to expand specifically on steve's response and note the big distinction that needs to be made for everyone is that this is primary the difference between calling a *function* and calling a *method* (which is a function that belongs to/defined for a class). with that instance (self), that me

Re: [Tutor] question on self

2012-03-13 Thread Bill Allen
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 wrote: > On 12/03/12 02:02, Michael Lewis wrote: > >> I have another me

Re: [Tutor] question on self

2012-03-12 Thread Alan Gauld
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 b

Re: [Tutor] question on self

2012-03-11 Thread Steve Willoughby
On 11-Mar-12 20:03, Steven D'Aprano wrote: On Sun, Mar 11, 2012 at 07:02:11PM -0700, Michael Lewis wrote: Why do I have to use "self.example" when calling a method inside a class? For example: def Play(self): '''find scores, reports winners''' self.scores = [] f

Re: [Tutor] question on self

2012-03-11 Thread Steven D'Aprano
On Sun, Mar 11, 2012 at 07:02:11PM -0700, Michael Lewis wrote: > Why do I have to use "self.example" when calling a method inside a class? > > For example: > > def Play(self): > '''find scores, reports winners''' > self.scores = [] > for player in range(self.players):

[Tutor] question on self

2012-03-11 Thread Michael Lewis
Why do I have to use "self.example" when calling a method inside a class? For example: def Play(self): '''find scores, reports winners''' self.scores = [] for player in range(self.players): print print 'Player', player + 1 self.score