Template « Format « Python Data Type Q&A

Home
Python Data Type Q&A
1.array
2.date
3.dictionary
4.Format
5.integer
6.List
7.numpy
8.regex
9.string
10.tuple
Python Data Type Q&A » Format » Template 

1. whats the best way to parse and replace the string with its values?    stackoverflow.com

I may have string like,

"""Hello, %(name)s,
how are you today, 
here is amount needed: %(partner_id.account_id.debit_amount)d
"""
what would be the best solution for such template may i need to combine regular expression and eval, ...

2. template in python    stackoverflow.com

How to write a function render_user which takes one of the tuples returned by userlist and a string template and returns the data substituted into the template, eg:

>>> tpl = "<a ...

3. Generate values for str.format style template strings from formatted output    stackoverflow.com

This might seem like a wierd requirement, but I am looking for a good implementation to do this. I have a dict like

vals = dict(red='#F00', green='#0F0', blue='#00F')
and a string like
tpl = '{red}:{green}:{blue}'
and ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.