[Tutor] question on self

Michael Lewis mjolewis at gmail.com
Mon Mar 12 03:02:11 CET 2012


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.scores.append(self.TakeTurns())

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()?

-- 
Michael J. Lewis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120311/6ab5a25c/attachment.html>


More information about the Tutor mailing list