Message262321
def public(thing, value=None):
if isinstance(thing, str):
mdict = sys._getframe(1).f_globals
name = thing
mdict[name] = thing # no need for retyping! ;)
else:
mdict = sys.modules[thing.__module__].__dict__
name = thing.__name__
dunder_all = mdict.setdefault('__all__', [])
dunder_all.append(name)
return thing
@public
def baz(a, b):
return a+ b
public('CONST1', 3)
CONST2 = 4
----------------------------
On the down side, you know somebody is going to @public a class' method -- how do we check for that? |
|
Date |
User |
Action |
Args |
2016-03-24 02:48:08 | ethan.furman | set | recipients:
+ ethan.furman, barry |
2016-03-24 02:48:08 | ethan.furman | set | messageid: <1458787688.43.0.0467845359815.issue26632@psf.upfronthosting.co.za> |
2016-03-24 02:48:08 | ethan.furman | link | issue26632 messages |
2016-03-24 02:48:08 | ethan.furman | create | |
|