Message262389
Not a fan. :/
How about getting your own copy of the public decorator initialized with the globals you pass in?
class Public:
def __init__(self, module):
"""
module should be the globals() dict from the calling module
"""
self.module = module
self.module.setdefault('__all__', [])
def __call__(self, thing, value=None):
if isinstance(thing, str):
self.module[thing] = value
else:
self.module[thing.__name__] = thing
and in use:
public = Public(globals())
@public
def baz(a, b):
#blah blah
public('CONST1', 2) |
|
Date |
User |
Action |
Args |
2016-03-25 00:14:52 | ethan.furman | set | recipients:
+ ethan.furman, barry, martin.panter |
2016-03-25 00:14:52 | ethan.furman | set | messageid: <1458864892.35.0.182710055779.issue26632@psf.upfronthosting.co.za> |
2016-03-25 00:14:52 | ethan.furman | link | issue26632 messages |
2016-03-25 00:14:52 | ethan.furman | create | |
|