"methods inside method" – class python2


I have this situation:

class ROUTER:
   def utils(self):
      def update(..) ...
      def reboot(..) ...

and I would like to invoke the sub methods of utils like this:


but not work (AttributeError: 'function' object has no attribute 'inf). Where am I wrong?
Thank you


Here is an example of the basic approach you need in order to implement your desired interface:

class Utils:
    def update(...): ...

    def reboot(...): ...

class Router:
   def __init__(...):
       self.utils = Utils(...)

myrouter = Router()

Answered By – Anentropic

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published