473,387 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

automatic referencing for variables?


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+'''{meta data}
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}";

can you do something like that in python?

thanks!

Mar 6 '06 #1
3 1276

se****@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+'''{meta data}
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_proce...ormatting.html

Mar 6 '06 #2
se****@village-buzz.com:
can you do something like that in python?


All you did is show us some string literals, but I guess you're looking
for string substitution:
http://docs.python.org/lib/typesseq-strings.html

This can be simplified, they say:
http://aspn.activestate.com/ASPN/Coo.../Recipe/305306

There's also Template strings:
http://www.python.org/dev/doc/newstyle/lib/node105.html

--
René Pijlman
Mar 6 '06 #3
ah!

this looks like what i am looking for..

i will try these both out..

thanks!

Mar 6 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: xcomm | last post by:
Hi All, <?php $vars= array("_SERVER","_SERVER","_SERVER","_SERVER","_SERVER","_SERVER"); foreach($vars as $var) { if(isset($$var))echo("$var: ${$var}<br>\n"); } ?> php.net:
1
by: Anthony Martin | last post by:
I've been reading the Java Language Specification, and in Chapter 16 there's an interesting topic called Definite Assignment. http://tinyurl.com/3fqk8 I'm wondering about the idea of "Deferred...
16
by: Robert Mark Bram | last post by:
Hi All! Is there a way to reference a window by name without doing something like this: open (, 'windowName'); The open method will open a blank window if there is no window with such a name....
5
by: cedric buerfent | last post by:
Hello NG, I ve a question concerning automatic generated source code. When I program the declarations of a class (and save it in a file called myclass.hh for example), its a boring work to...
1
by: KavvY | last post by:
Hi, Considering the code posted below can anyone explain to me why the following behaviour occurs? On page load the testFillDataGrid() function gets called and the variable sel is...
2
by: Axel | last post by:
Hi, a question about something that seems very simple at first glance: is it possible to reference other controls of a subform in a query window without referencing through the parent form? I...
6
by: main() | last post by:
I'm a newbie. These questions arose out of my curiosity, Please pardon me if this questions sound silly. 1. Why are the automatic variables are left uninitialized by default( as i understand...
58
by: Jorge Peixoto de Morais Neto | last post by:
I was reading the code of FFmpeg and it seems that they use malloc just too much. The problems and dangers of malloc are widely known. Malloc also has some overhead (although I don't know what is...
4
by: acw | last post by:
I am trying to understand how IE handles automatic tag variables. I know that IE will create a global variable each time it finds a tag with its name or id attribute set. If you have more than...
25
by: sidd | last post by:
In the following code: int i = 5; ---it goes to .data segment int j; ---it goes to bss segment int main() { int c; int i = 5; ---stack
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.