automatic referencing for variables?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sergio@village-buzz.com

    #1

    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+'''{me tatdata}
    h2. Author:
    {metadata:autho r}Len Sweet{metadata}
    h1. Exegesis
    {metadata:exege sis}'''+exegesi s+'''{metadata}
    h1. Text Alive
    {metadata:texta live}'''+textAl ive+'''{metadat a}
    h1. Illustrations, Illuminations, Animations:
    {metadata:illus trations}'''+il lustrations+''' {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}";

    can you do something like that in python?

    thanks!

  • gene tani

    #2
    Re: automatic referencing for variables?


    sergio@village-buzz.com wrote:[color=blue]
    > 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+'''{me tatdata}
    > h2. Author:
    > {metadata:autho r}Len Sweet{metadata}
    > h1. Exegesis
    > {metadata:exege sis}'''+exegesi s+'''{metadata}
    > h1. Text Alive
    > {metadata:texta live}'''+textAl ive+'''{metadat a}
    > h1. Illustrations, Illuminations, Animations:
    > {metadata:illus trations}'''+il lustrations+''' {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}";
    >[/color]

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


    Learn how to slice, subset, reverse, split, replace, and count substrings in Python strings. Improve your string manipulation skills now!


    Comment

    • Rene Pijlman

      #3
      Re: automatic referencing for variables?

      sergio@village-buzz.com:[color=blue]
      >can you do something like that in python?[/color]

      All you did is show us some string literals, but I guess you're looking
      for string substitution:


      This can be simplified, they say:


      There's also Template strings:


      --
      René Pijlman

      Comment

      • sergio@village-buzz.com

        #4
        Re: automatic referencing for variables?

        ah!

        this looks like what i am looking for..

        i will try these both out..

        thanks!

        Comment

        Working...