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


Groups > comp.lang.python > #49460

Re: Closures in leu of pointers?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <joshua.landau.ws@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'definitions': 0.07; 'list...': 0.07; 'though:': 0.07; 'string': 0.09; '[1,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'itself.': 0.14; 'expression,': 0.16; 'merely': 0.16; 'sorting': 0.16; 'sorts': 0.16; 'to:name:tim chase': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'logical': 0.24; 'cc:2**0': 0.24; 'sort': 0.25; 'define': 0.26; 'pass': 0.26; 'header:In-Reply- To:1': 0.27; 'tim': 0.29; "doesn't": 0.30; 'list:': 0.30; 'message-id:@mail.gmail.com': 0.30; '>>>>': 0.31; 'asks': 0.31; 'chase': 0.31; "d'aprano": 0.31; 'int,': 0.31; 'steven': 0.31; 'class': 0.32; 'skip:_ 10': 0.34; 'common': 0.35; 'received:google.com': 0.35; 'words,': 0.36; 'doing': 0.36; 'subject:?': 0.36; 'being': 0.38; 'how': 0.40; 'number,': 0.60; "you're": 0.61; 'more': 0.64; 'nobody': 0.68; 'square': 0.74; 'power': 0.76; 'multiplying': 0.84; '2013': 0.98
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 :cc:content-type; bh=bSonapMBuKyT954eqGrt/ehAIUAkIAVVurHwtwJm0X8=; b=fSLBPQppIQAHpoLuBj+4J7Svl7w5DMZpU/u0dgqZUNKgKUHca5GamHO2huB+qqK8BG o4lIbosSNAhIgLDnGGmowM5hhCvcvEMZqRBFRUfEL3EyMlCKuV89b01G1BHeJQho3RCS FK7+nPtAKoMIZ56sVn6b5QduxYmOpOnCclr7AV5IQsXqlM9ivPdLFcpW0Z3j2E7w5Xs2 5YS/KKhTsvHrF4xKGlVfLjLxctVLy/PKOKhcqchZivXnRk5ECgRGZ0e5+ySR/4tNMZ1G VDhg9fdoNEghlVFVp+4voMVLqeqEqcgoaOpGRc8dv+zTZlLPaazGlwPpirJgR19lt/JE aFmQ==
X-Received by 10.112.52.97 with SMTP id s1mr8857069lbo.8.1372536201694; Sat, 29 Jun 2013 13:03:21 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <20130629144258.79e86bb0@bigbox.christie.dr>
References <2a2072e3-4b12-4ada-872c-1240d2379928@googlegroups.com> <mailman.3984.1372500107.3114.python-list@python.org> <bc798729-f935-448d-9d62-c409b2d12e76@googlegroups.com> <51CEE8E9.4070703@gmail.com> <51CF1309.1010504@rece.vub.ac.be> <mailman.4001.1372530961.3114.python-list@python.org> <51cf332f$0$29999$c3e8da3$5496439d@news.astraweb.com> <20130629144258.79e86bb0@bigbox.christie.dr>
From Joshua Landau <joshua.landau.ws@gmail.com>
Date Sat, 29 Jun 2013 21:02:41 +0100
Subject Re: Closures in leu of pointers?
To Tim Chase <tim@thechases.com>
Content-Type text/plain; charset=UTF-8
Cc python-list <python-list@python.org>
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 <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4009.1372536209.3114.python-list@python.org> (permalink)
Lines 42
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1372536209 news.xs4all.nl 15875 [2001:888:2000:d::a6]:49774
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:49460

Show key headers only | View raw


On 29 June 2013 20:42, Tim Chase <tim@thechases.com> wrote:
> On 2013-06-29 19:19, Steven D'Aprano wrote:
>> Nobody ever asks why Python doesn't let you sort an int, or take
>> the square of a list...
>
> just to be ornery, you can sort an int:
>
>>>> i = 314159265
>>>> ''.join(sorted(str(i)))
> '112345569'

To be yet more ornery, you are merely sorting the string
representation of an int.

You can sort an int, though:

    [1].sort()

You may say "No! You are sorting a *list*!" However, is it not fair to
say that with:

    [1, 2, 3, 4, 5].sort()

you are sorting integers? That is just a common english idiom. Hence,
"[1].sort()" sorts an int.

> And I suppose, depending on how you define it, you can square a list:

>From Wikipedia, "a square is the result of multiplying a number, or
other expression, by itself. In other words, squaring is
exponentiation to the power 2."

This means that the only logical definitions would be "list*list" and "list**2".

However, it can be done!

    class PowList(list):
        def __pow__(self, other): pass

    PowList([1, 2, 3])**2

// Because being a pedant is more fun when you're doing it competitively //

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


Thread

Closures in leu of pointers? cts.private.yahoo@gmail.com - 2013-06-29 02:34 -0700
  Re: Closures in leu of pointers? Fábio Santos <fabiosantosart@gmail.com> - 2013-06-29 10:42 +0100
  Re: Closures in leu of pointers? Peter Otten <__peter__@web.de> - 2013-06-29 12:01 +0200
    Re: Closures in leu of pointers? cts.private.yahoo@gmail.com - 2013-06-29 04:21 -0700
      Re: Closures in leu of pointers? cts.private.yahoo@gmail.com - 2013-06-29 04:44 -0700
        Re: Closures in leu of pointers? Peter Otten <__peter__@web.de> - 2013-06-29 14:12 +0200
          Re: Closures in leu of pointers? cts.private.yahoo@gmail.com - 2013-06-29 05:26 -0700
            Re: Closures in leu of pointers? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-29 15:37 +0100
              Re: Closures in leu of pointers? cts.private.yahoo@gmail.com - 2013-06-29 07:48 -0700
        Re: Closures in leu of pointers? Michael Torrie <torriem@gmail.com> - 2013-06-29 07:56 -0600
        Re: Closures in leu of pointers? Michael Torrie <torriem@gmail.com> - 2013-06-29 12:36 -0600
      Re: Closures in leu of pointers? Michael Torrie <torriem@gmail.com> - 2013-06-29 08:02 -0600
      Re: Closures in leu of pointers? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-06-29 19:02 +0200
        Re: Closures in leu of pointers? rusi <rustompmody@gmail.com> - 2013-06-29 10:33 -0700
          Re: Closures in leu of pointers? cts.private.yahoo@gmail.com - 2013-06-29 11:37 -0700
            Re: Closures in leu of pointers? Michael Torrie <torriem@gmail.com> - 2013-06-29 12:58 -0600
            Re: Closures in leu of pointers? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-29 18:59 +0000
        Re: Closures in leu of pointers? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-29 18:51 +0000
          Re: Closures in leu of pointers? Michael Torrie <torriem@gmail.com> - 2013-06-29 13:04 -0600
          Re: Closures in leu of pointers? rusi <rustompmody@gmail.com> - 2013-06-29 12:11 -0700
      Re: Closures in leu of pointers? Michael Torrie <torriem@gmail.com> - 2013-06-29 12:35 -0600
        Re: Closures in leu of pointers? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-29 19:19 +0000
          Re: Closures in leu of pointers? Tim Chase <tim@thechases.com> - 2013-06-29 14:42 -0500
            Re: Closures in leu of pointers? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-30 01:41 +0000
          Re: Closures in leu of pointers? Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-29 21:02 +0100
          Re: Closures in leu of pointers? Michael Torrie <torriem@gmail.com> - 2013-06-29 16:02 -0600
      Re: Closures in leu of pointers? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-29 18:45 +0000
        Re: Closures in leu of pointers? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-29 19:00 +0000
        Re: Closures in leu of pointers? cts.private.yahoo@gmail.com - 2013-06-29 12:20 -0700
          Re: Closures in leu of pointers? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-29 19:33 +0000
            Re: Closures in leu of pointers? cts.private.yahoo@gmail.com - 2013-06-29 12:34 -0700
            Re: Closures in leu of pointers? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-29 13:47 -0600
            Re: Closures in leu of pointers? Terry Reedy <tjreedy@udel.edu> - 2013-06-29 16:53 -0400
              Re: Closures in leu of pointers? rusi <rustompmody@gmail.com> - 2013-06-30 01:56 -0700
                Re: Closures in leu of pointers? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-30 11:22 +0000
                Re: Closures in leu of pointers? rusi <rustompmody@gmail.com> - 2013-06-30 04:42 -0700
            Re: Closures in leu of pointers? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-29 15:21 -0600
              Re: Closures in leu of pointers? cts.private.yahoo@gmail.com - 2013-06-29 14:30 -0700
            Re: Closures in leu of pointers? Terry Reedy <tjreedy@udel.edu> - 2013-06-30 00:32 -0400
            Re: Closures in leu of pointers? Chris Angelico <rosuav@gmail.com> - 2013-06-30 15:08 +1000
              Re: Closures in leu of pointers? rusi <rustompmody@gmail.com> - 2013-06-30 00:36 -0700
            Re: Closures in leu of pointers? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-29 23:46 -0600
              Re: Closures in leu of pointers? alex23 <wuwei23@gmail.com> - 2013-07-01 14:57 +1000
              Re: Closures in leu of pointers? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-01 07:36 +0000
            Re: Closures in leu of pointers? Chris Angelico <rosuav@gmail.com> - 2013-06-30 15:59 +1000
            Re: Closures in leu of pointers? Terry Reedy <tjreedy@udel.edu> - 2013-06-30 02:11 -0400
            Re: Closures in leu of pointers? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-30 00:24 -0600
          Re: Closures in leu of pointers? Michael Torrie <torriem@gmail.com> - 2013-06-29 16:03 -0600
      Re: Closures in leu of pointers? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-29 13:23 -0600
      Re: Closures in leu of pointers? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-06-30 12:07 +0200
      Re: Closures in leu of pointers? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-30 11:13 -0600
      Re: Closures in leu of pointers? Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-30 11:18 -0600

csiph-web