I like to make really modular programs but it gets hard to track which functions are subroutines of other functions. Thus, I'd like to define subroutines inside of the parent functions. With Python's object-definition of functions this would be a cogent implementation:
>>> def football():
... self = football
...
... logo = "Nike"
...
... self.display_logo(self)
...
>>> def display_logo(self):
... print(self.logo)
>>> football.display_logo = display_logo
>>> football()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 6, in football
File "<stdin>", line 2, in display_logo
AttributeError: 'function' object has no attribute 'logo'
Unfortunately this doesn't work. Neither does it work by trying to access 'logo' by itself. I could define every variable in the function with a self. prefix, but is there any more pragmatic way to create subroutines that have access to the parent function's internal variables upon being called?