Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43751
| From | Serhiy Storchaka <storchaka@gmail.com> |
|---|---|
| Subject | Re: a couple of things I don't understand wrt lists |
| Date | 2013-04-17 12:35 +0300 |
| References | <mailman.668.1366126626.3114.python-list@python.org> <2rGdndNcINM-tvPMnZ2dnUVZ_jqdnZ2d@giganews.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.718.1366191316.3114.python-list@python.org> (permalink) |
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)))
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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