Python Iterables struggling using map() built-in

Roy Smith roy at panix.com
Thu Dec 11 20:55:07 EST 2014


In article <mailman.16880.1418342293.18130.python-list at python.org>,
 Ian Kelly <ian.g.kelly at gmail.com> wrote:

> I never said that functions can't be used as namespaces. I said that
> functions are *bad* namespaces, and I gave reasons why I think this is true.

An excellent example of functions acting as namespaces is nosetest's 
@attr() decorator.  We use this, for example, to tag certain test cases 
as being reliant on facebook being up(*):

    @attr('facebook', 'services')
    def test_some_facebook_thing():
        # whatever

this lets us turn all those tests on or off with a single switch.  The 
way @attr() is implemented, it sets attributes on the decorated 
function.  It's the most logical and obvious place to store a piece of 
information about a test case -- right on the test case itself.

Similarly, we've got tests that we annotate as being dependent on itunes 
being reachable, depending on certain data existing in the database(**), 
being too slow to want to run all the time(**), etc.

(*) and please don't tell me that tests shouldn't depend on external 
services.

(**) see first footnote



More information about the Python-list mailing list