Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31857 > unrolled thread
| Started by | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| First post | 2012-10-21 13:06 -0600 |
| Last post | 2012-10-21 13:06 -0600 |
| 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: get each pair from a string. Ian Kelly <ian.g.kelly@gmail.com> - 2012-10-21 13:06 -0600
| From | Ian Kelly <ian.g.kelly@gmail.com> |
|---|---|
| Date | 2012-10-21 13:06 -0600 |
| Subject | Re: get each pair from a string. |
| Message-ID | <mailman.2599.1350846404.27098.python-list@python.org> |
On Sun, Oct 21, 2012 at 12:58 PM, Vincent Davis <vincent@vincentdavis.net> wrote: > x = 'apple' > for f in range(len(x)-1): > print(x[f:f+2]) > > @Ian, > Thanks for that I was just looking in to that. I wonder which is faster I > have a large set of strings to process. I'll try some timings if I get a > chance later today. The solution you came up with is probably faster, but less general -- it will only work on sliceable sequences like strings, not arbitrary iterables.
Back to top | Article view | comp.lang.python
csiph-web