[Tutor] class methods: using class vars as args?

Alex Hall mehgcap at gmail.com
Sun May 23 21:40:13 CEST 2010


Hello all,
I know Python reasonably well, but I still run into basic questions
which those over on the other python list request I post here instead.
I figure this would be one of them:
Why would this not work:

class c(object):
 def __init__(self, arg1, arg2):
  self.arg1=arg1
  self.arg2=arg2

 def doSomething(self, arg3=self.arg1):
  ...

The above results in an error that "name 'self' is not defined". Why
can I not set the default values of a method's arguments to class vars
like that? Thanks!


-- 
Have a great day,
Alex (msg sent from GMail website)
mehgcap at gmail.com; http://www.facebook.com/mehgcap


More information about the Tutor mailing list