Ethan Furman added the comment:

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)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26632>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to