Re[2]: [Tutor] Comparative code questions: Python vs. Rebol
Tim Johnson
tim@johnsons-web.com
Thu Jan 16 12:58:36 2003
Hello Magnus and antormuhin:
I want to thank you and everyone else on the list for
contributing to this thread. My original intent was to
gather some code examples that illustrated "self-composing"
code approaches in several languages. I will probably use
both the 'exec' approach and Danny's 'dictionary' approach
if only to stay in the context of the article that I'm=20
writing.
For those of you who have problems with that, I assure
you that disclaimers will be posted! :-) Please no
flaming or scolding!
Just for your own edification, I have written an article on
an 'html generation approach in rebol. This can be read
(among other places) at=20
http://www.johnsons-web.com/col/code-corner.txt.html
I do a lot of cgi programming, have done some in python,
lots in c/c++, but now mostly in rebol.
I'm adding some python modules to one of my projects,
will be using the Mysql package and HTMLgen (tentatively).
- among others -
This is a great mailing list. You'll see me here again,
I'm sure as a bewildered newbie!
Thanks to all
-tim-
* antonmuhin =ED=E0 rambler.ru <antonmuhin@rambler.ru> [030116 05:02]:
> Hello Magnus,
>=20
> ML> Or if you don't like Lisp, use a class...
> ML> I'll make it slightly more generic.
>=20
> ML> >>> class Tag:
> ML> ... def __init__(self, tag):
> ML> ... self.tag =3D tag
> ML> ... def __call__(self, text):
> ML> ... return "<%s>%s</%s>" % (self.tag, text, self.tag)
> ML> ...
> ML> >>> H1 =3D Tag('h1')
> ML> >>> HTML =3D Tag('html')
> ML> >>> print HTML(H1('Hello')+'\nHow are you.\n'+H1('Goodbye')+'\nSee=
you=20
> ML> later.\n')
> ML> <html><h1>Hello</h1>
> ML> How are you.
> ML> <h1>Goodbye</h1>
> ML> See you later.
> ML> </html>
>=20
> As usual Magnus suggested nice solution :) I only think that Magnus's
> solution is better situated for more complex problems.
>=20
> After I sent the previous letter, more Pythonic solution came in my
> mind (the only problem that it seems to demand something like
> Python2.2)
>=20
> def H(level):
> def f(s):
> return "<H%d>" % level + s + "</H%d>" % level
> return f
>=20
>=20
> --=20
> Best regards,
> anton mailto:antonmuhin@rambler.ru
>=20
>=20
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
--=20
Tim Johnson <tim@johnsons-web.com>
http://www.alaska-internet-solutions.com
http://www.johnsons-web.com