OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Python web pages, PHP-style [closed]

  • Thread starter Thread starter Basj
  • Start date Start date
B

Basj

Guest
I have used Python and PHP a lot, but just out of curiosity, is there a version of Python that uses a similar paradigm to PHP for dynamic creation of html pages, i.e. like this:

Code:
<html>
<body>

<?py                        # similar to <?php ... ?>
for i in range(10):
    print '<div>Hello%i</div>' % i
?>

</body>
</html>

?



Note 1: I'm not speaking about Django, Flask, Bottle, Twisted, etc. that don't use such syntax.

Note 2: The suggested code would be like this in PHP:


Code:
<html>
<body>

<?php 
for ($i = 0; $i < 10; $i++)
{ 
    echo '<div>Hello' . $i . '</div>'; 
}
?>

</body>
</html>
<p>I have used Python and PHP a lot, but just out of curiosity, <strong>is there a version of Python that uses a similar paradigm to PHP for dynamic creation of html pages</strong>, i.e. like this:</p>

<pre><code><html>
<body>

<?py # similar to <?php ... ?>
for i in range(10):
print '<div>Hello%i</div>' % i
?>

</body>
</html>
</code></pre>

<p>?</p>

<hr>

<p><em>Note 1: I'm <strong>not</strong> speaking about Django, Flask, Bottle, Twisted, etc. that don't use such syntax.</em></p>

<p><em>Note 2: The suggested code would be like this in PHP:</em></p>

<pre><code><html>
<body>

<?php
for ($i = 0; $i < 10; $i++)
{
echo '<div>Hello' . $i . '</div>';
}
?>

</body>
</html>
</code></pre>
 
Top