[BangPypers] chaining string operations..

Vishal vsapre80 at gmail.com
Fri Mar 25 13:15:16 CET 2011


On Fri, Mar 25, 2011 at 3:31 PM, Senthil Kumaran <orsenthil at gmail.com>wrote:

> On Fri, Mar 25, 2011 at 03:22:02PM +0530, Vishal wrote:
>
> > I have a string that can be many megabytes worth memory size, and i
> > want to
>
> If you have got that string from a file like object, instead of
> loading the entire string in memory you could iterate through the file
> object to load one line at time. This will help provided the string is
> has line-separators.
>
> Otherwise you could store in a mock StringIO file like object and
> iterate, if the string is heavy to handle in memory.
>
> >
> > Now I would like to chain these replacements into something like this:
> >
> > >>> s1 = s.replacements((' a', 'S'), (' \t', '\n'), ('C#', '\n')))
> >
> > Is there a known way of doing this currently in Python, apart from
> producing
>
> Here is one recipe to do multiple string replacement in python in a
> single shot.
>
>
> http://uthcode.sarovar.org/pycon2010/strings.html#making-multiple-replacements-in-a-string-in-a-single-pass
>
> --
> Senthil
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>

Thanks for his one. This is what I was looking for.

-- 
Thanks and best regards,
Vishal Sapre


More information about the BangPypers mailing list