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


Groups > comp.lang.python > #43772

Re: a couple of things I don't understand wrt lists

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ned@nedbatchelder.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'referring': 0.07; '[0]': 0.09; 'lines:': 0.09; 'python:': 0.09; 'used.': 0.09; 'cc:addr :python-list': 0.11; 'def': 0.12; 'cleaned': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'memory': 0.22; 'cc:addr:python.org': 0.22; 'header:User-Agent:1': 0.23; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply- To:1': 0.27; 'returned': 0.30; 'larry': 0.31; 'object.': 0.31; 'subject:lists': 0.35; 'there': 0.35; 'object,': 0.36; 'two': 0.37; 'list': 0.37; '8bit%:86': 0.38; 'pm,': 0.38; 'new': 0.61; 'line!': 0.84
Date Wed, 17 Apr 2013 14:36:34 -0400
From Ned Batchelder <ned@nedbatchelder.com>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5
MIME-Version 1.0
To 88888 Dihedral <dihedral88888@googlemail.com>
Subject Re: a couple of things I don't understand wrt lists
References <mailman.668.1366126626.3114.python-list@python.org> <2rGdndNcINM-tvPMnZ2dnUVZ_jqdnZ2d@giganews.com> <mailman.718.1366191316.3114.python-list@python.org> <2f8ccb0c-3fb5-4675-993a-4cd3d30dc3a1@googlegroups.com>
In-Reply-To <2f8ccb0c-3fb5-4675-993a-4cd3d30dc3a1@googlegroups.com>
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
Cc 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.731.1366223819.3114.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366223819 news.xs4all.nl 2172 [2001:888:2000:d::a6]:60302
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:43772

Show key headers only | View raw


On 4/17/2013 12:10 PM, 88888 Dihedral wrote:
> Serhiy Storchaka於 2013年4月17日星期三UTC+8下午5時35分07秒寫道:
>> 17.04.13 07:57, Larry Hudson написав(ла):
>>
>>> So using a list comprehension you can do it in two lines:
>>> def get_rule(num):
>>>       bs = bin(num)[2:]
>>>       return [0] * (8 - len(bs)) + [int(i) for i in bs]
>>
>>
>> You can do it in one line!
>>
>>
>>
>> def get_rule(num):
>>
>>        return list(map(int, '{:08b}'.format(num)))
> Well, a new object is returned and can be used.
> Then who is going to clean up the object when required?

This is a key thing to understand about Python: memory is managed 
automatically, no one has to clean up the object.  Once there are no 
names referring to the object, it will be cleaned up automatically.

--Ned.

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


Thread

a couple of things I don't understand wrt lists aaB <mecagonoisician@gmail.com> - 2013-04-16 17:37 +0200
  Re: a couple of things I don't understand wrt lists John Gordon <gordon@panix.com> - 2013-04-16 16:43 +0000
  Re: a couple of things I don't understand wrt lists Larry Hudson <orgnut@yahoo.com> - 2013-04-16 21:57 -0700
    Re: a couple of things I don't understand wrt lists Serhiy Storchaka <storchaka@gmail.com> - 2013-04-17 12:35 +0300
      Re: a couple of things I don't understand wrt lists 88888 Dihedral <dihedral88888@googlemail.com> - 2013-04-17 09:10 -0700
        Re: a couple of things I don't understand wrt lists Ned Batchelder <ned@nedbatchelder.com> - 2013-04-17 14:36 -0400
          Re: a couple of things I don't understand wrt lists Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-18 04:46 +1000
        Re: a couple of things I don't understand wrt lists Chris Angelico <rosuav@gmail.com> - 2013-04-18 04:42 +1000
      Re: a couple of things I don't understand wrt lists 88888 Dihedral <dihedral88888@googlemail.com> - 2013-04-17 09:10 -0700

csiph-web