[python] Re: PSP - python server pages

David Michal david_michal na seznam.cz
Úterý Říjen 25 13:24:23 CEST 2005


Zdravim,
Cerpal jsem z techto prikladu: 
http://svn.webwareforpython.org/Webware/tags/Release-0_9b1/PSP/Examples/
A uz chapu kde je chyba, jako obvykle v tom ze jsem priklady necetl cele. :)
Viz.

<p>Dave Wallace (dwallace na delanet.com) has written a module that will convert python code that uses braces for indentation into properly whitespace indented python syntax.  This is pretty nifty, and very useful for PSP.  
<p>  The whitespace significance in python syntax is difficult in PSP because HTML is the exact opposite.  Whitespace doesn't matter, and neither do carriage-returns or anything else.  So that makes the melding of Python and HTML a challenge.<p>
So this is one solution.
<p>Take out all of the whitespace significance, and just use braces.
<p>This module allows you to use braces where you would normally be hitting &lt;return&gt;&lt;tab&gt;.  You can put the opening brace ( { ) on the line befoe the block starts, or on the first line of the block.  Same kind of deal for the closing brace ( } ). You still need to have the colon (:) on the line right before the block starts.  That's just part of python.
<p>To enable this funtionality in PSP, you have to set braces as the indent type for your page.  So you add this directive to your PSP page:<br>
&lt;%@ page indentType="braces" %&gt;<p>
<p>
<p>This is a little test of the functionality.
<p>

<% for i in range(5): { %>
I'm number <%=i%>  <br>
<% } %>

<p>Click on ViewSource over on the left to see the source for this page.
<p><p>

Takze u PSP se da formatovani nahradit zavorkami.
David

mick wrote:

>Cus, zkousel jsem to a nefachalo mi to.
>Urcite tam nemuzou byt {, } .
>Fakt slo jen o formatovani.
>Python v tomhle neni moc stastny.
>Zlate zavorky :))
>Dikec za odpoved Michal
>
>  
>





Další informace o konferenci Python