What is the most pythonic way to build up large strings?
Asaf Las
roegltd at gmail.com
Sat Feb 8 06:28:03 EST 2014
On Saturday, February 8, 2014 11:56:46 AM UTC+2, cstru... at gmail.com wrote:
> On Saturday, February 8, 2014 3:13:54 AM UTC-5, Asaf Las wrote:
>
>
>
> >
>
> > note, due to strings are immutable - for every line in sum operation
>
> >
>
> > above you produce new object and throw out older one. you can write
>
> >
>
> > one string spanned at multiple lines in very clear form.
>
> >
>
>
>
> I get what your saying here about immutable strings.
> Is there anyway efficiently build large strings with
> lots of conditional inclusions, repetitive sections
> built dynamically by looping (see the field section above)etc.
> Is there a mutable string class?
Check this approach if it suits you:
str_t= '<script type="text/javascript' \
'<src="/{0}/jquery/jqueryui.js"></script>' \
'<script type="text/javascript'\
'src="/{1}/jquery/jquery.js"></script>'.format('bella', 'donna')
print(str_t)
More information about the Python-list
mailing list