default argument

j vickroy jim.vickroy at noaa.gov
Tue May 11 15:59:36 EDT 2010


Back9 wrote:
> Hi,
> 
> Is this grammer working in Python?
> 
> class test:
>   self._value = 10
>   def func(self, self._value)
> 
> When i try it, it complains about undefined self.
> 
> i don't know why.
> 
> TIA

... not exactly; try:

class Test:
    _value = 10
    def func(self):
       print id(self._value), self._value
       print id(Test._value), Test._value

t = Test()
t.func()



More information about the Python-list mailing list