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


Groups > comp.lang.python > #43767

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

Newsgroups comp.lang.python
Date 2013-04-17 09:10 -0700
References <mailman.668.1366126626.3114.python-list@python.org> <2rGdndNcINM-tvPMnZ2dnUVZ_jqdnZ2d@giganews.com> <mailman.718.1366191316.3114.python-list@python.org>
Subject Re: a couple of things I don't understand wrt lists
From 88888 Dihedral <dihedral88888@googlemail.com>
Message-ID <mailman.728.1366215818.3114.python-list@python.org> (permalink)

Show all headers | View raw


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?

Back to comp.lang.python | Previous | NextPrevious 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