Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #27627
| References | <CAE7MaQbrdVbbFWDJ8GHuoybT2SNPfZyyMFU_beBc_zMKpBHPFg@mail.gmail.com> <CAEtwbM0PwcSb6v5MZ=Dr3s9TVFoXzCOywd=JfWFfBUcM-RFLcQ@mail.gmail.com> <CAPTjJmr7JqsDx6ypjVODTvy315fFYZacNgns60QXmM+zJ5p+Xw@mail.gmail.com> |
|---|---|
| From | Kamil Kuduk <kamil.kuduk@gmail.com> |
| Date | 2012-08-22 13:06 +0200 |
| Subject | Re: help me debug my "word capitalizer" script |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3645.1345633589.4697.python-list@python.org> (permalink) |
On Wed, Aug 22, 2012 at 12:41 PM, Chris Angelico <rosuav@gmail.com> wrote:
> Why less? Why not just redirect input?
Yeah, my bad, I somehow used to do it, for grep too, and I know that
this is slower
> Though, this isn't really on topic for Python.
I would still go with regexp, something like:
with open('myfile.txt', 'rw) as file:
print "".join(re.sub(r'\w{3,}', lambda(match):
match.group(0).title(), line) for line in file)
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: help me debug my "word capitalizer" script Kamil Kuduk <kamil.kuduk@gmail.com> - 2012-08-22 13:06 +0200
csiph-web