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: 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>': 0.22; 'separate': 0.22; 'tests': 0.22; 'adds': 0.24; 'lets': 0.24; 'logical': 0.24; '>': 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: References: <004e01d01173$e1641c10$a42c5430$@gmail.com> <5484e3d8$0$13013$c3e8da3$5496439d@news.astraweb.com> <54866372$0$12991$c3e8da3$5496439d@news.astraweb.com> <54878f8a$0$13010$c3e8da3$5496439d@news.astraweb.com> <54881159$0$2817$c3e8da3$76491128@news.astraweb.com> <54891733$0$2817$c3e8da3$76491128@news.astraweb.com> <548a28b4$0$13001$c3e8da3$5496439d@news.astraweb.com> From: Ian Kelly Date: Fri, 12 Dec 2014 00:36:45 -0700 Subject: Re: Python Iterables struggling using map() built-in To: Python 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 --047d7bfd0ae0eb0ba50509fff66b Content-Type: text/plain; charset=UTF-8 On Thu, Dec 11, 2014 at 6:55 PM, Roy Smith wrote: > > In article , > Ian Kelly 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. --047d7bfd0ae0eb0ba50509fff66b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Thu, Dec 11, 2014 at 6:55 PM, Roy Smith <roy@panix.com> wrote:
>
> In artic= le <mailman.16880.1418342293.18130.python-list@python.org>,
>= =C2=A0Ian Kelly <ian.g.kelly@g= mail.com> wrote:
>
> > I never said that functions ca= n't be used as namespaces. I said that
> > functions are *bad*= namespaces, and I gave reasons why I think this is true.
>
> A= n excellent example of functions acting as namespaces is nosetest's
= > @attr() decorator.=C2=A0 We use this, for example, to tag certain test= cases
> as being reliant on facebook being up(*):
>
> = =C2=A0 =C2=A0 @attr('facebook', 'services')
> =C2=A0 = =C2=A0 def test_some_facebook_thing():
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 = # whatever
>
> this lets us turn all those tests on or off with= a single switch.=C2=A0 The
> way @attr() is implemented, it sets att= ributes on the decorated
> function.=C2=A0 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 e= ntities 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 apar= t because they're in separate namespaces.

In t= he nosetest example, the 'facebook' attribute always means the same= thing no matter which functions you apply it to. Conceptually speaking, ea= ch instance of the attribute is the same annotation. The expression test_so= me_facebook_thing.facebook doesn't perform the role of a namespace beca= use it's used to signify the presence of that annotation, not to identi= fy something.

A similar example from the standard = library is the functools.lru_cache decorator, which adds a cache_info funct= ion to the wrapped function. However, the cache_info function always perfor= ms 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 names= pace.
--047d7bfd0ae0eb0ba50509fff66b--