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


Groups > comp.lang.python > #5964

Re: count strangeness

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From James Stroud <jstroud@mbi.ucla.edu>
Newsgroups comp.lang.python
Subject Re: count strangeness
Date Sat, 21 May 2011 23:56:36 -0700
Organization A noiseless patient Spider
Lines 37
Message-ID <irac35$k6a$1@dont-email.me> (permalink)
References <ira8ti$6no$1@dont-email.me> <mailman.1905.1306045890.9059.python-list@python.org>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Sun, 22 May 2011 06:56:37 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="OO30NsQ1a/gonbMmIt37AQ"; logging-data="20682"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ANA8GNe85PCDHIX/6Y+N+7oH3ilU5oVQ="
User-Agent Thunderbird 2.0.0.19 (Macintosh/20081209)
In-Reply-To <mailman.1905.1306045890.9059.python-list@python.org>
Cancel-Lock sha1:miVNpk0Ex9BYOCoLFcy+YFc1z90=
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:5964

Show key headers only | View raw


Peter Otten wrote:
> James Stroud wrote:
>> WTF?
> 
> Put the code into a file, run it -- and be enlightened ;)

Compare the follower to the last.

tal 77% cat eraseme.py
#! /usr/bin/env python

class C:
   def __init__(self):
     self.data = []
   def doit(self, count=[0]):
     for c in self.data:
       c.doit()
     count[0] += 1
     print count[0]

c = C()
c.data.extend([C() for i in xrange(10)])
c.doit()
tal 78% python2.7 eraseme.py
1
2
3
4
5
6
7
8
9
10
11

James

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


Thread

count strangeness James Stroud <jstroud@mbi.ucla.edu> - 2011-05-21 23:02 -0700
  Re: count strangeness Chris Rebert <crebert@ucsd.edu> - 2011-05-21 23:27 -0700
    Re: count strangeness James Stroud <jstroud@mbi.ucla.edu> - 2011-05-21 23:32 -0700
      Re: count strangeness James Stroud <jstroud@mbi.ucla.edu> - 2011-05-21 23:39 -0700
      Re: count strangeness Chris Rebert <crebert@ucsd.edu> - 2011-05-21 23:55 -0700
        Re: count strangeness James Stroud <jstroud@mbi.ucla.edu> - 2011-05-22 00:03 -0700
  Re: count strangeness Peter Otten <__peter__@web.de> - 2011-05-22 08:31 +0200
    Re: count strangeness James Stroud <jstroud@mbi.ucla.edu> - 2011-05-21 23:34 -0700
      Re: count strangeness Peter Otten <__peter__@web.de> - 2011-05-22 09:13 +0200
    Re: count strangeness James Stroud <jstroud@mbi.ucla.edu> - 2011-05-21 23:56 -0700
  Re: count strangeness Roy Smith <roy@panix.com> - 2011-05-22 09:36 -0400

csiph-web