Variables in strings..
Richard Brodie
R.Brodie at rl.ac.uk
Mon Jul 24 10:08:18 EDT 2000
More information about the Python-list mailing list
Mon Jul 24 10:08:18 EDT 2000
- Previous message (by thread): Variables in strings..
- Next message (by thread): Variables in strings..
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Gabriel Ambuehl" <gabriel_ambuehl at buz.ch> wrote in message news:71330494285.20000724135012 at buz.ch... > I really dislike all that HTML generators no matter if they are for > Perl or Python. I've got my very own view about how I want to have my > HTML code looking (imagine strongly idented, ie each element has got > it's own identation level, <table> constructs). Using some modules > for it just won't do the job for me... If you prefer, rolling your own template functions wouldn't be too hard. For example, if you want to interpolate a list into a string: >>> def format(template, *args): for element in args: ... template = re.sub('#', str(element), template, 1) ... return(template) ... >>> format('Value is # and # and #', 2, 3, 4) 'Value is 2 and 3 and 4' No doubt re hackers could optimise the code further. One could even (horrors) write a function that takes a string and does Perl style substitution from the enclosing namespace.
- Previous message (by thread): Variables in strings..
- Next message (by thread): Variables in strings..
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list