[Tutor] Accessing methods in same class

Max S. maxskywalker1 at gmail.com
Sun Nov 6 22:28:58 CET 2011


Oh.  Sorry.  It's 500 lines, so I'll just post an example.  Windows Vista
and Python 3, just because I forgot.

class K:

def __init__(self): doThis()

def doThis(self): print("Hi.")

k = K()


>From what I understand by your help, the code

class K:

def __init__(self): self.doThis()

def doThis(self): print("Hi.")

k = K()

should work.  Thank you for coping with my lack of code to work with.

On Sun, Nov 6, 2011 at 4:23 PM, Peter Lavelle
<lists at solderintheveins.co.uk>wrote:

> Hi,
>
> Could you post a copy of the code you are working on, so we can help you
> better with this?
>
> Usually, when calling a method in the same class you use the syntax:
> self.method_name()
>
> 'self' refers to an attribute or method within the same class.
>
> Sorry, if this does not help you.
>
> Regards
>
> Peter Lavelle
> ______________________________**_________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111106/f9db9e21/attachment.html>


More information about the Tutor mailing list