I'm unsure if this is possible but I was wondering if there is a way to get a variable from an outer scope without passing it as an argument.
I've played around with global()
and inspect
but i'm having issues trying to get the attribute.
Here's what i'm trying to do:
class Example:
@staticmethod
def query(**kwargs):
print(f.read())
with open(__file__) as f:
Example.query(foo='bar')
a
that you're calling with the context manager? What isget_b
? What was the purpose ofas b:
? – roganjosh Oct 23 '19 at 21:45c()
needsreturn b
– Barmar Oct 23 '19 at 21:54