我只想在类hello中访问some_object: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()
答案 0 :(得分:0)
你可以让some_object
成为班级本身的一员。
在'__main__'
部分下,将some_object
设置为hello
类的类成员,如下所示:
hello.some_object = some_object
然后更改hello.GET
以返回班级成员:
class hello:
def GET(self, name):
return self.some_object