quetz-mod_python-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sterling Hughes <sterl...@bumblebury.com>
Subject Re: Talking about PSP: Internals
Date Thu, 10 Apr 2003 19:14:28 GMT
> >I agree with you (we need to offer more than php).  One thing I think
> >you underestimate however is just how important python syntax is.  Yes,
> >whitespace is a bitch when it comes to embedding python in html ('{' and
> >'}' are optional additions to whitespace, when you use PSP).
> >
> I don't see how whitespace is a problem. You just need to think more 
> python-centric than html-centric.
> But then again, the whole framework requires that you mark you python 
> with psp tags... and that might require a different approach (see my 
> other mail)

Yeah, it does.  But you can still easily embed large amounts of python
code at the top of the file, for example.  Take my first psp


Its mixing a whitespace agnostic language with a whitespace pedantic
language. :)  When you have multiple levels of nesting it becomes a mess
unless you use brackets.

> And you can do funky things with objects :-) Not sure how the PHP ones 
> work, but you can do just about anything with the Python ones.
> Metaclasses, inspection, function wrapping ... very cool. For a simple 
> example of function wrapping:
> def header(title):
>   return "<head><title>%s</title></head>" % title
> def body(text):
>   return "<body><p>%s</p></body>" % text
> def mypage(title, text):
>   return "<html>" + header(title) + body(text) + "</html>"
> def logfunction(fn):
>   def logfn(*args):
>     print "calling function %r with args %r" % (fn, args)
>     result = apply(fn, args)
>     print "leaving function %r, result %r" % (fn, args)
>     return result
>   return logfn
> header, body, mypage = [logfunction(fn) for fn in (header, body, mypage)]
> print mypage("title","this is the text")

i agree - python objects simply rock.  They're so simple, yet they allow
you to be complex, as opposed to other OO languages (*cough* Java) which
are complex so you can be simple. :)

"Whether you think you can or think you can't -- you are right." 
    - Henry Ford

View raw message