PyThon How do I pass a object to another class? -


i want access some_object within class hello: def get()

from wsgiref.simple_server import make_server import web  urls = (     '/(.*)', 'hello' )  class hello:     def get(self, name):         return some_object   if __name__ == '__main__':      data = []     some_object = parentobj.func(data)      app = web.application(urls, globals())     app.run() 

you make some_object member of class itself.

under '__main__' section, set some_object class member of hello class, so:

hello.some_object = some_object 

then change hello.get return member of class:

class hello:     def get(self, name):         return self.some_object 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -