Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32133 > unrolled thread
| Started by | Christian Heimes <christian@python.org> |
|---|---|
| First post | 2012-10-25 17:25 +0200 |
| Last post | 2012-10-25 17:25 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: bit count or bit set && Python3 Christian Heimes <christian@python.org> - 2012-10-25 17:25 +0200
| From | Christian Heimes <christian@python.org> |
|---|---|
| Date | 2012-10-25 17:25 +0200 |
| Subject | Re: bit count or bit set && Python3 |
| Message-ID | <mailman.2848.1351178765.27098.python-list@python.org> |
Am 25.10.2012 16:47, schrieb Charles Hixson:
> In Python3 is there any good way to count the number of on bits in an
> integer (after an & operation)?
Simple, easy, faster than a Python loop but not very elegant:
bin(number).count("1")
Christian
Back to top | Article view | comp.lang.python
csiph-web