automatic referencing for variables?

gene tani gene.tani at gmail.com
Mon Mar 6 12:57:06 EST 2006


sergio at village-buzz.com wrote:
> i am SURE i am using the wrong terminology...
>
> but what i would like to do is something like this:
>
>         pageContent='''
> {toc}
> h1. Header Section
> h2. Date:
> {metadata:date}'''+date+'''{metatdata}
> h2. Author:
> {metadata:author}Len Sweet{metadata}
> h1. Exegesis
> {metadata:exegesis}'''+exegesis+'''{metadata}
> h1. Text Alive
> {metadata:textalive}'''+textAlive+'''{metadata}
> h1. Illustrations, Illuminations, Animations:
> {metadata:illustrations}'''+illustrations+'''{metadata}
> h1. Worship Resources
> '''
>
> but rather than have:
>
> '''+variable+'''
>
> have something a little cleaner..
>
> in php, you can do something like
>
> text="this is text where variable = {variable}";
>

ou can use template strings or string formatting on a dict:

http://ftp.python.org/doc/lib/node109.html
http://diveintopython.org/html_processing/dictionary_based_string_formatting.html




More information about the Python-list mailing list