class Test:
def somemethod(self):
def write():
print 'hello'
write()
x = Test()
x.somemethod()
write() is a function that will be used several times through somemethod(). somemethod() is the only function within the class that will require it's use so it seems silly to define it outside of somemethod(). Closure seems like the way to go.
When I run that code, I get the following error:
TypeError: somemethod() takes exactly 2 arguments (1 given)
What am I doing wrong? Is self
getting passed to write()? :/