Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #82417

Re: Python Iterables struggling using map() built-in

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.031
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'subject:Python': 0.06; 'attribute': 0.07; 'attributes': 0.09; 'namespace': 0.09; 'performs': 0.09; 'subject:using': 0.09; 'wrapped': 0.09; 'def': 0.12; 'itself.': 0.14; 'attributes,': 0.16; 'distinct': 0.16; 'implemented,': 0.16; 'namespace.': 0.16; 'roy': 0.16; 'switch.': 0.16; 'wrote:': 0.18; 'library': 0.18; 'thu,': 0.19; 'example': 0.22; 'email addr:gmail.com&gt;': 0.22; 'separate': 0.22; 'tests': 0.22; 'adds': 0.24; 'lets': 0.24; 'logical': 0.24; '&gt;': 0.26; 'task': 0.26; 'certain': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; "doesn't": 0.30; 'dec': 0.30; 'sets': 0.30; 'skip:& 60': 0.30; 'skip:@ 10': 0.30; 'message- id:@mail.gmail.com': 0.30; 'piece': 0.31; 'cases': 0.33; 'role': 0.34; "can't": 0.35; 'agree': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'method': 0.36; 'similar': 0.36; 'example,': 0.37; 'turn': 0.37; 'two': 0.37; 'being': 0.38; 'e.g.': 0.38; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'expression': 0.60; 'ian': 0.60; 'most': 0.60; 'tell': 0.60; 'identify': 0.61; 'skip:t 30': 0.61; 'tag': 0.61; 'facebook': 0.61; 'matter': 0.61; 'information': 0.63; 'name': 0.63; 'happen': 0.63; 'more': 0.64; 'different': 0.65; 'great': 0.65; 'between': 0.67; 'smith': 0.68; 'apart': 0.72; 'acts': 0.74; 'obvious': 0.74; 'article': 0.77; 'distinguish': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=Du7kEDN+Lrjzcd6PqdWepcPYQhoot+S3BIGwNV6RBZ8=; b=YbdCnr1qRKtXpMZp9LXZwfV/dSCnOtFCG20jPKPEcWmAWArnE1iSQO0JPAYRutpe0m JWyBQpy8Uf87ySBEYrOb+2rOO9IwRUq3PJri0mw82FujLRzn3+XTUPhwwHvkJffXhETd sZQ6l7r0Z/yM67hLlcuXnn64BjonnQ/9N8tN5CVFCnCn6pP+/YtsxWpMgzoLXVRL/46w kWo/PidqLP2mIcCsWIrAYTVLn73jMXuRCbh36PVAetcreMKaeVEA5Mn4VDKMp9iX0vc8 neNDVLOc/UTJUZkpj/jXHq7+rvGzOmZ6dheOMGL3SsyO6JiA9gxX60eek2L1JCYqsAHr BZww==
X-Received by 10.70.42.142 with SMTP id o14mr24494645pdl.17.1418369847460; Thu, 11 Dec 2014 23:37:27 -0800 (PST)
MIME-Version 1.0
In-Reply-To <roy-93D6AC.20543611122014@news.panix.com>
References <004e01d01173$e1641c10$a42c5430$@gmail.com> <m61roh$i5m$1@ger.gmane.org> <CALwzid=79=i3Sez3fQYV7xU2bEAL4_ohPqxhuYj59Y5ihXk1Zg@mail.gmail.com> <mailman.16685.1417976998.18130.python-list@python.org> <5484e3d8$0$13013$c3e8da3$5496439d@news.astraweb.com> <roy-3F4751.19122007122014@news.panix.com> <54866372$0$12991$c3e8da3$5496439d@news.astraweb.com> <m65vrc$j0t$1@ger.gmane.org> <mailman.16776.1418155635.18130.python-list@python.org> <54878f8a$0$13010$c3e8da3$5496439d@news.astraweb.com> <roy-0FD505.21442409122014@news.panix.com> <54881159$0$2817$c3e8da3$76491128@news.astraweb.com> <mailman.16818.1418230065.18130.python-list@python.org> <54891733$0$2817$c3e8da3$76491128@news.astraweb.com> <mailman.16875.1418335266.18130.python-list@python.org> <548a28b4$0$13001$c3e8da3$5496439d@news.astraweb.com> <mailman.16880.1418342293.18130.python-list@python.org> <roy-93D6AC.20543611122014@news.panix.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Fri, 12 Dec 2014 00:36:45 -0700
Subject Re: Python Iterables struggling using map() built-in
To Python <python-list@python.org>
Content-Type multipart/alternative; boundary=047d7bfd0ae0eb0ba50509fff66b
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16894.1418369850.18130.python-list@python.org> (permalink)
Lines 84
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1418369850 news.xs4all.nl 2930 [2001:888:2000:d::a6]:46720
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:82417

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Thu, Dec 11, 2014 at 6:55 PM, Roy Smith <roy@panix.com> wrote:
>
> In article <mailman.16880.1418342293.18130.python-list@python.org>,
>  Ian Kelly <ian.g.kelly@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.

I agree this is a great use of function attributes, but this is an example
of tags or annotations, not namespaces. The purpose of namespaces is to
distinguish between different entities of the same name, e.g. 'pow' and
'math.pow' are two distinct functions that both happen to be named pow. We
can tell them apart because they're in separate namespaces.

In the nosetest example, the 'facebook' attribute always means the same
thing no matter which functions you apply it to. Conceptually speaking,
each instance of the attribute is the same annotation. The expression
test_some_facebook_thing.facebook doesn't perform the role of a namespace
because it's used to signify the presence of that annotation, not to
identify something.

A similar example from the standard library is the functools.lru_cache
decorator, which adds a cache_info function to the wrapped function.
However, the cache_info function always performs the same task in relation
to the particular function it decorates, so in this regard it acts more
like an object method than like a name in a namespace.

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Python Iterables struggling using map() built-in Chris Angelico <rosuav@gmail.com> - 2014-12-08 05:29 +1100
  Re: Python Iterables struggling using map() built-in Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-08 10:33 +1100
    Re: Python Iterables struggling using map() built-in Chris Angelico <rosuav@gmail.com> - 2014-12-08 10:50 +1100
      Re: Python Iterables struggling using map() built-in Roy Smith <roy@panix.com> - 2014-12-07 19:27 -0500
        Re: Python Iterables struggling using map() built-in Chris Angelico <rosuav@gmail.com> - 2014-12-08 11:35 +1100
          Re: Python Iterables struggling using map() built-in Steven D'Aprano <steve@pearwood.info> - 2014-12-08 09:40 +0000
            Re: Python Iterables struggling using map() built-in Chris Angelico <rosuav@gmail.com> - 2014-12-08 20:50 +1100
            Re: Python Iterables struggling using map() built-in Roy Smith <roy@panix.com> - 2014-12-08 19:02 -0500
    Re: Python Iterables struggling using map() built-in Roy Smith <roy@panix.com> - 2014-12-07 19:12 -0500
      Re: Python Iterables struggling using map() built-in Chris Angelico <rosuav@gmail.com> - 2014-12-08 11:34 +1100
        Re: Python Iterables struggling using map() built-in Roy Smith <roy@panix.com> - 2014-12-07 19:45 -0500
          Re: Python Iterables struggling using map() built-in Chris Angelico <rosuav@gmail.com> - 2014-12-08 12:00 +1100
          Re: Python Iterables struggling using map() built-in MRAB <python@mrabarnett.plus.com> - 2014-12-08 03:09 +0000
      Re: Python Iterables struggling using map() built-in Terry Reedy <tjreedy@udel.edu> - 2014-12-07 19:38 -0500
        Re: Python Iterables struggling using map() built-in Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-12-08 18:06 +1300
      Re: Python Iterables struggling using map() built-in Ned Batchelder <ned@nedbatchelder.com> - 2014-12-07 20:06 -0500
      Re: Python Iterables struggling using map() built-in Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-09 13:50 +1100
        Re: Python Iterables struggling using map() built-in Terry Reedy <tjreedy@udel.edu> - 2014-12-09 00:03 -0500
          Re: Python Iterables struggling using map() built-in Steven D'Aprano <steve@pearwood.info> - 2014-12-09 06:40 +0000
        Re: Python Iterables struggling using map() built-in Terry Reedy <tjreedy@udel.edu> - 2014-12-09 15:06 -0500
          Re: Python Iterables struggling using map() built-in Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-10 11:10 +1100
            Re: Python Iterables struggling using map() built-in Chris Angelico <rosuav@gmail.com> - 2014-12-10 11:20 +1100
            Re: Python Iterables struggling using map() built-in Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-12-10 00:24 +0000
            Re: Python Iterables struggling using map() built-in Roy Smith <roy@panix.com> - 2014-12-09 21:44 -0500
              Re: Python Iterables struggling using map() built-in Steven D'Aprano <steve@pearwood.info> - 2014-12-10 09:24 +0000
                Re: Python Iterables struggling using map() built-in Chris Angelico <rosuav@gmail.com> - 2014-12-10 20:32 +1100
                Re: Python Iterables struggling using map() built-in Marko Rauhamaa <marko@pacujo.net> - 2014-12-10 12:58 +0200
                Re: Python Iterables struggling using map() built-in Ian Kelly <ian.g.kelly@gmail.com> - 2014-12-10 09:46 -0700
                Re: Python Iterables struggling using map() built-in Steven D'Aprano <steve@pearwood.info> - 2014-12-11 04:01 +0000
                Re: Python Iterables struggling using map() built-in Ian Kelly <ian.g.kelly@gmail.com> - 2014-12-11 15:00 -0700
                Re: Python Iterables struggling using map() built-in Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-12 10:28 +1100
                Re: Python Iterables struggling using map() built-in Ian Kelly <ian.g.kelly@gmail.com> - 2014-12-11 16:57 -0700
                Re: Python Iterables struggling using map() built-in Roy Smith <roy@panix.com> - 2014-12-11 20:55 -0500
                Re: Python Iterables struggling using map() built-in Ian Kelly <ian.g.kelly@gmail.com> - 2014-12-12 00:36 -0700
                Re: Python Iterables struggling using map() built-in Chris Angelico <rosuav@gmail.com> - 2014-12-12 11:44 +1100
                Re: Python Iterables struggling using map() built-in Terry Reedy <tjreedy@udel.edu> - 2014-12-10 12:48 -0500
                Re: Python Iterables struggling using map() built-in Ian Kelly <ian.g.kelly@gmail.com> - 2014-12-10 13:32 -0700
                Re: Python Iterables struggling using map() built-in Terry Reedy <tjreedy@udel.edu> - 2014-12-10 23:17 -0500
    Re: Python Iterables struggling using map() built-in Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-12-08 18:00 +1300

csiph-web