Includeing Python in text files

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paolo Pantaleo

    Includeing Python in text files

    I am working on this:

    I have a text file, containig certain section in the form
    <?py
    python code here
    py?>

    I parse the text file and substitute the python code with its result
    [redirecting sys.stdin to a StringIO]. It something like php or
    embedded perl.

    So my little toy works not bad, but I was wondering if such a feature
    already existed, if yes, can you point me out some links?

    Thnx
    PAolo

    --
    if you have a minute to spend please visit my photogrphy site:

  • Diez B. Roggisch

    #2
    Re: Includeing Python in text files

    Paolo Pantaleo wrote:
    [color=blue]
    > I am working on this:
    >
    > I have a text file, containig certain section in the form
    > <?py
    > python code here
    > py?>
    >
    > I parse the text file and substitute the python code with its result
    > [redirecting sys.stdin to a StringIO]. It something like php or
    > embedded perl.
    >
    > So my little toy works not bad, but I was wondering if such a feature
    > already existed, if yes, can you point me out some links?[/color]

    Its a templating system, and there are a gazillion out there. Some of them
    are listed here:




    Diez



    Comment

    • looping

      #3
      Re: Includeing Python in text files


      Paolo Pantaleo wrote:[color=blue]
      > I am working on this:
      >
      > I have a text file, containig certain section in the form
      > <?py
      > python code here
      > py?>
      >
      > I parse the text file and substitute the python code with its result
      > [redirecting sys.stdin to a StringIO]. It something like php or
      > embedded perl.
      >
      > So my little toy works not bad, but I was wondering if such a feature
      > already existed, if yes, can you point me out some links?
      >
      > Thnx
      > PAolo
      >
      > --
      > if you have a minute to spend please visit my photogrphy site:
      > http://mypic.co.nr[/color]

      Like Diez had said, use a template system or you could look at COG:


      Comment

      • Laurent Pointal

        #4
        Re: Includeing Python in text files

        Paolo Pantaleo a écrit :[color=blue]
        > I am working on this:
        >
        > I have a text file, containig certain section in the form
        > <?py
        > python code here
        > py?>
        >
        > I parse the text file and substitute the python code with its result
        > [redirecting sys.stdin to a StringIO]. It something like php or
        > embedded perl.
        >
        > So my little toy works not bad, but I was wondering if such a feature
        > already existed, if yes, can you point me out some links?[/color]

        Yes Python Inside HTML, like this example from Karrigell docs
        ( http://karrigell.sourceforge.net/en/...insidehtml.htm ):

        The current date is
        <% import time
        print time.strftime(" %d:%m:%y",time. localtime(time. time()))
        %>


        See http://karrigell.sourceforge.net/

        A+

        Laurent.

        Comment

        • Erik Max Francis

          #5
          Re: Includeing Python in text files

          Paolo Pantaleo wrote:
          [color=blue]
          > I am working on this:
          >
          > I have a text file, containig certain section in the form
          > <?py
          > python code here
          > py?>
          >
          > I parse the text file and substitute the python code with its result
          > [redirecting sys.stdin to a StringIO]. It something like php or
          > embedded perl.
          >
          > So my little toy works not bad, but I was wondering if such a feature
          > already existed, if yes, can you point me out some links?[/color]

          Another standalone templating system is EmPy:



          --
          Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/
          San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
          What would physics look like without gravitation?
          -- Albert Einstein

          Comment

          • Chris Smith

            #6
            Re: Includeing Python in text files

            Diez B. Roggisch wrote:[color=blue]
            > Paolo Pantaleo wrote:
            >
            >[color=green]
            >>I am working on this:
            >>
            >>I have a text file, containig certain section in the form
            >><?py
            >> python code here
            >>py?>
            >>
            >>I parse the text file and substitute the python code with its result
            >>[redirecting sys.stdin to a StringIO]. It something like php or
            >>embedded perl.
            >>
            >>So my little toy works not bad, but I was wondering if such a feature
            >>already existed, if yes, can you point me out some links?[/color]
            >
            >
            > Its a templating system, and there are a gazillion out there. Some of them
            > are listed here:
            >
            > http://www.cherrypy.org/wiki/Choosin...latingLanguage
            >
            >
            > Diez
            >
            >
            >[/color]
            I'm just getting into programming so this may be a dumb question...but
            why would you want to do this? What is templating good for?

            Chris

            Comment

            • Paolo Pantaleo

              #7
              Re: Includeing Python in text files

              2006/5/23, Chris Smith <mc_anjo@tamu.e du>:[color=blue]
              > Diez B. Roggisch wrote:[color=green]
              > > Paolo Pantaleo wrote:
              > >
              > >[color=darkred]
              > >>I am working on this:
              > >>
              > >>I have a text file, containig certain section in the form
              > >><?py
              > >> python code here
              > >>py?>
              > >>
              > >>I parse the text file and substitute the python code with its result
              > >>[redirecting sys.stdin to a StringIO]. It something like php or
              > >>embedded perl.
              > >>
              > >>So my little toy works not bad, but I was wondering if such a feature
              > >>already existed, if yes, can you point me out some links?[/color]
              > >
              > >
              > > Its a templating system, and there are a gazillion out there. Some of them
              > > are listed here:
              > >
              > > http://www.cherrypy.org/wiki/Choosin...latingLanguage
              > >
              > >
              > > Diez
              > >
              > >
              > >[/color]
              > I'm just getting into programming so this may be a dumb question...but
              > why would you want to do this? What is templating good for?
              >
              > Chris
              >
              > --
              > http://mail.python.org/mailman/listinfo/python-list
              >[/color]
              Well php is base on this principle, most (server side) dynamic sites
              are based on some template sistem

              PAolo

              --
              if you have a minute to spend please visit my photogrphy site:

              Comment

              Working...