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 eric.snow
Recipients Jimbofbx, eric.snow
Date 2011-12-29.20:09:54
SpamBayes Score 1.9845102e-06
Marked as misclassified No
Message-id <1325189395.71.0.541970672833.issue13678@psf.upfronthosting.co.za>
In-reply-to
Content
Interesting thought, the syntax seems unnecessary. Adding new syntax to the language is something that happens rarely and only with a _lot_ of consideration.

As a slightly more verbose alternative, currently you can do this:

    def fail_if_defined(*args, namespace):
        for name in args:
            if name in namespace:
                raise AlreadyBoundError(name)

And in your code you would put the following where you cared about it:
    
    fail_if_defined("FILE", "header", namespace=locals())

You could even drop the namespace parameter (since it's sort of boilerplate):

    def fail_if_defined(*args):
        namespace = inspect.currentframe().f_back.f_locals
        for name in args:
            if name in namespace:
                raise AlreadyBoundError(name)

However, if you are going to the trouble of sticking those in place (or of selectively using a new syntax), you are likely paying attention to the the situation already, rendering either solution unnecessary.

Ultimately, this is something better addressed instead by keeping your functions small, by being a little more cautious in naming, and particularly by careful unit testing.
History
Date User Action Args
2011-12-29 20:09:55eric.snowsetrecipients: + eric.snow, Jimbofbx
2011-12-29 20:09:55eric.snowsetmessageid: <1325189395.71.0.541970672833.issue13678@psf.upfronthosting.co.za>
2011-12-29 20:09:55eric.snowlinkissue13678 messages
2011-12-29 20:09:54eric.snowcreate