This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ethan.furman
Recipients barry, ethan.furman, martin.panter
Date 2016-03-25.00:14:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1458864892.35.0.182710055779.issue26632@psf.upfronthosting.co.za>
In-reply-to
Content
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)
History
Date User Action Args
2016-03-25 00:14:52ethan.furmansetrecipients: + ethan.furman, barry, martin.panter
2016-03-25 00:14:52ethan.furmansetmessageid: <1458864892.35.0.182710055779.issue26632@psf.upfronthosting.co.za>
2016-03-25 00:14:52ethan.furmanlinkissue26632 messages
2016-03-25 00:14:52ethan.furmancreate