I am trying to organize my functions into classes. I want to use the attribute self.file_list from class 'Outer' in class 'Inner'.
class Outer:
"""Outer Class"""
def __init__(self, file_list):
self.file_list=file_list
## instantiating the 'Inner' class
self.inner = self.Inner()
## inner class
class Inner:
"""First Inner Class"""
def __init__(self):
print (Outer.file_list) <-- this line doesn't work
pass
clean =Outer (['cats', 'dogs'])
However I am getting this error:
<ipython-input-63-0dfab321da74> in __init__(self)
10 """First Inner Class"""
11 def __init__(self):
---> 12 print (self.file_list)
13
14 pass
AttributeError: 'Inner' object has no attribute 'file_list'
How do I access the attribute self.file_list in the inner init method? Or what is the conventional way of grouping functions together in a class?