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
Post a Comment