#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2002
    Posts
    2
    Rep Power
    0

    Python: The 'Include' feature


    Hello,

    I just want to know whether or not Python can 'include' HTML or scripts like PHP.

    I know the PHP script to include is:

    <?php include(" SOMETHING HERE "); ?>

    but I don't know what is the include script for Python. Does anyone know anything about it? Does Python even have this feature? If not, does Zope have it?

    Any help would be very nice.
    Thanks!

    Ye Tan
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    89
    Rep Power
    13
    you can check out Spyce at http://spyce.sourceforge.net/
    Spyce let's you insert python in your Python documents to generate dynamic content just like PHP does. It has an include module which should do what you want.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2002
    Posts
    2
    Rep Power
    0
    thanks jimmy2k1,

    But Spyce requires installation. I want the Python 'include' feature. Do you have any other suggestions?
  6. #4
  7. chown python:users\ /world
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Texas Tech
    Posts
    95
    Rep Power
    15
    Why not just use the 'import' statement?
    Hartmann
    badice.com
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    383
    Rep Power
    13
    Originally posted by Hartmann
    Why not just use the 'import' statement?
    I'm pretty sure the import statement isn't quite the same as a preprocessor style inclusion.

    Zope does have support for this sort of thing, but unfortunately, I don't remember the syntax for it. But setting up zope is even harder than setting up Spyce. Spyce is one answer, as is Webware for Python. One of those two seems to be the easiest route to get where you are going.
    Debian - because life's too short for worrying.
    Best. (Python.) IRC bot. ever.
  10. #6
  11. chown python:users\ /world
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Texas Tech
    Posts
    95
    Rep Power
    15
    But he wants to know if Python can include files like PHP does... Which is exactly what import is. You can include other Python files you create with the import statement. I don't think he needs anything preprocessed.
    Hartmann
    badice.com
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    383
    Rep Power
    13
    Originally posted by Hartmann
    But he wants to know if Python can include files like PHP does... Which is exactly what import is. You can include other Python files you create with the import statement. I don't think he needs anything preprocessed.
    No, that seems to be the problem - he doesn't want to include other Python files. He wants to include HTML. Which would end up trying to be parsed by the interpreter when the script is called. Which would, of course, be bad.
    Debian - because life's too short for worrying.
    Best. (Python.) IRC bot. ever.
  14. #8
  15. chown python:users\ /world
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Texas Tech
    Posts
    95
    Rep Power
    15
    Oh, I see.... Kind of misinterpreted the post. Sorry 'bout that.

    What part of Houston you from? I am originally from Sugar Land.
    Hartmann
    badice.com

IMN logo majestic logo threadwatch logo seochat tools logo