class scope questions
Steve Purcell
stephen_purcell at yahoo.com
Fri Feb 9 05:29:54 EST 2001
Ben de Luca wrote:
> if i do this
>
> class a:
> dog='woof'
>
> def blah():
> something
> how do i call a
> how do i get soemthing in blah to refernce dog? either to read it or write
> to it
Your 'blah' should have a 'self' parameter because it is a method of class 'a'.
Then the answer is;-
class A:
dog = 'woof'
def bark(self):
print self.dog
-Steve
--
Steve Purcell, Pythangelist
Get testing at http://pyunit.sourceforge.net/
Available for consulting and training.
"Even snakes are afraid of snakes." -- Steven Wright
More information about the Python-list
mailing list