Python noob here. How do I get hold of the 'inner' function within the 'fib' function?
from time import sleep
class Fibonacci(object):
def __init__(self, a, b, limit=50):
self.a = a
self.b = b
self.limit = limit
def fib(self):
while self.a < self.limit:
c = self.a + self.b
sleep(1)
print self.a,
self.b = self.a
self.a = c
def inner(self):
print 'Damn it! Just print already!'
j = Fibonacci(0,1,2)
j.fib()
## This doesn't work. Gives an "AttibuteError: 'function' object has no attribute 'inner'"
j.fib.inner()
inner()from within the definition offib(), but not from outside of it. What are you trying to do?innerfrom outside offib, without changing howinneris defined.fibinsideFibonacci(yeah, i know it's a class and not a function) with a dot operator, I should be able to access a function inside another function like that. Oh wellinnerafterinner = "fubar".