[Tutor] scope, visibility?
Samuel de Champlain
samueldechamplain at gmail.com
Mon Nov 1 18:01:16 CET 2010
I am learning python. To practice, I am coding a hangman application in
pyGTK.
Here are my imports:
import pygtk
pygtk.require('2.0')
import gtk
import random
Here is my main class:
class PenduGTK:
Inside the class is a method with a bit of code:
def masque(chaine,liInd=0):
i = 0
lenght = len(chaine)
The offending line is the one with len(chaine)
Here are the error messages:
penduGTK.py
Traceback (most recent call last):
File "/home/xxx/bin/penduGTK.py", line 23, in enter_callback
self.lblMot.set_text(self.masque(self.motChoisi))
File "/home/xxx/bin/penduGTK.py", line 44, in masque
lenght = len(chaine)
AttributeError: PenduGTK instance has no attribute '__len__'
I would think it has to do with namespaces, scopes and visibility. But how
do I refer to built-in functions from inside a class?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101101/3650d38b/attachment.html>
More information about the Tutor
mailing list