Code and XML/HTML Section Tags

Stephen Lukacs (2) iquanta.org/instruct/python

the body section...

π is 3.141592653589793 as imported from math under body.

Good Morning World! It's Monday, December 29, 2025 @ 05:22 AM, of alpha1:
A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Here it is again, but slightly different. Its still Monday, December 29, 2025 @ 05:22 AM, of alpha1:
A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

And here of alpha2:
A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
noticing the differences in alpha1 and alpha2 list inline creation and the date formatting of strftime.

the body section amended/concatenated at the end...

"""
reference: https://iquanta.org/instruct/python ::: Example 3, Code and HTML Section Tags ::: Stephen Lukacs, Ph.D. ©2021-09-19

this is again all server-side processing.  this example introduces server-side sections, <header>, <body>, and 
<footer>, which are not python or py4web designators, but designators specific to this programming site to help the user 
section off their code and display so that it is easier to write and manage their code.  more on these sections later, but 
the <header>, <body>, and <footer> sections are used below as code examples.  anything not in those 3 sections are run as pure 
executable code under this python/py4web server.

you'll notice under the <body> section how it's a combinations of pure python code surrounded by double square brackets, 
{{ and }}, py4web html functions, like XML under the double square brackets, and pure html tagged elements, i.e., <p>, 
<span>, etc.  at this point you're learning 3 programming languages, i.e., python, py4web, and HTML.

python lists are an extremely powerful structure, especially when you embrace split() of strings to create lists from 
strings, and join of lists to create strings from lists.  also, list.append(), list.extend(), and list.sort(), and, can 
fill many lists with inline single loops.
"""
#comments start with # symbol, comments are non-executing comments built into code to relay messages to self and others.
#this is pure python code up until the "<body>" tagged section below.
#this allows for more variables then just the rtn variable.
#you might have to look into python loops, and the ord and chr functions, google it.
#bos...begin of pure python section...
from yatl.helpers import XML
from math import pi
from datetime import datetime

#the following extends the list
alpha1 = [chr(i) for i in range(ord('A'), ord('Z')+1)]
alpha1.extend([chr(i) for i in range(ord('a'), ord('z')+1)])
alpha1.extend([chr(i) for i in range(ord('0'), ord('9')+1)])
alpha1 = ', '.join(alpha1)

#the following appends the list to create a list of 3 lists
alpha2 = [[chr(i) for i in range(ord('A'), ord('Z')+1)]]
alpha2.append([chr(i) for i in range(ord('a'), ord('z')+1)])
alpha2.append([chr(i) for i in range(ord('0'), ord('9')+1)])
alpha2 = '\n'.join([', '.join(l) for l in alpha2])

#just some extra variables
now = datetime.now()
greeting = "Morning" if (now.hour < 12) else ("Afternoon" if (now.hour < 18) else "Evening")
now = now.strftime("%A, %B %d, %Y @ %I:%M %p")
string = XML(f"<b><i>Good {greeting} World!</i></b>  It's {now}")

#the header, body and footer tagged sections allows rendering of pure HTML script and tags with the delimited {{ & }} insertions of python variables and code, as shown:
#eos...end of pure python section...
<body>
<!--comments under HTML code or a view have to be surrounded by these two delimitors.  AND will not be displayed by the client-side web browser but will be shown under the page source.-->
<p>the body section...</p>
<p>&pi; is {{=pi}} as imported from math under body.</p>
<p>{{=string}}, of <span style="font-weight:bold;">alpha1</span>:<br/>{{=XML(alpha1.replace('\n', '<br />'))}}</p>
<p>Here it is again, but slightly different.  Its still {{=now}}, of <span style="font-weight:bold;">alpha1</span>:<br/>{{=XML(alpha1.replace('\n', '<br />'))}}</p>
<p>And here of <span style="font-weight:bold;">alpha2</span>:<br/>{{=XML(alpha2.replace('\n', '<br />'))}}<br/>noticing the differences in alpha1 and alpha2 list inline creation and the date formatting of strftime.</p>
</body>

<footer>
the footer section, always below the body.<br/>
testing the footer section 1 2 3 .. .
</footer>

<body>
<p>the body section amended/concatenated at the end...</p>
</body>

<footer>
<br/>and again, the footer, testing 1 2 3 .. .
</footer>

<header>
the header section, always above the body.
</header>