Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9248893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:03:33+00:00 2026-06-18T10:03:33+00:00

Can we write in python language (or maybe exist such a web framework), that

  • 0

Can we write in python language (or maybe exist such a web framework), that we could write Python and html tags as in PHP language.

Could we have such a python file structure:

some_python_file.py:

<html>
<head>
     <title>Lol</title>
<head>
<body>
    My PyWeb Slang
</body>
</html>

<!-- this part should be python -->
<?py
    from Eternity import Kiss

    love = Kiss.Forever()
    print "%s" % love
?>

sorry i’m writting with caps: DISAMBIGUATION:

You can see, that template use in each line {% goodies %} or <%= goodies %>

{% extends "layout.html" %}
{% block body %}
  <ul>
  {% for user in users %}
    <li><a href="{{ user.url }}">{{ user.username }}</a></li>
  {% endfor %}
  </ul>
{% endblock %}

But in PHP:

<div>Good Morning, Sun!</div>
<?php

     echo "Happy!";
     echo "Hi, WaterLand!";

?>

If Python could do it that way, it should be like:

<div>Good Morning, Sun!</div>

<?py

     print "%s" % "Happy!"
     print "%s" % "Hi, WaterLand!";

?>

Got the ideia, or I need to be more explicit?

Thank You. 🙂

Hm, if so:

Could we write with mod_python something like (extending [morphyn] example from below):

<html>
<%
    greet = 'Hello Wee!'
    answer = 'Hello Bee!'
%>
<h1><%= greet %></h1>
<h2><%= answer %></h2>
</html>

There you can see more than 2’u lines into <% … %>
Could we?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T10:03:34+00:00Added an answer on June 18, 2026 at 10:03 am

    This is not exactly what you’re asking for, but the proper way to do this is to use a template engine. Take a look at Jinja2. Django also provides its own template engine.

    Update:

    By default, Python cannot be embedded in HTML pages. There is however at least one way of doing it. mod_python, a module for Apache2, offers the kind of feature you want with PSP (Python Server Pages).

    <html>
    <%
        greet = 'Hello'
    %>
    <h1><%= greet %></h1>
    </html>
    

    Keep in mind that mixing logic and presentation is generally not a good idea. The proper way to go is still to use a template engine, as stated in my original answer. You may have very good reasons to do what you want to do, but probably not.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

when I write Python code from the interpreter I can type dir() to have
I am developing in python a file class that can read and write a
I have some programming knowledge, I can write console applications in Python, Java, and
One of my favorite features about python is that you can write configuration files
How can we write a python (with CPython) binding to a Java library so
When I write code in Python with exception handling I can write code like:
How can I write to files using Python (on Windows) and use the Unix
In C#, Python and/or VB.NET, how can I write a method of a class
How can i open file in python and write to it multiple times? I
I would like to write a League Fixture generator in python, but I can't.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.