I'm coming from Tcl-world ...
Andreas.Leitgeb at siemens.at
Fri Aug 2 15:36:52 CEST 2002
I'm somewhat experienced in Tcl-scripting, and I generally still like
Tcl, but there are some nasty edges in Tcl, which is the reason
why I had a look at Python.
I bought a small intro-book about python (it deals with 2.0 to 2.2 with
some prospects to 3.0), which I've now almost read through, and now there
are some goodies in Tcl, which I'm sure have their counterparts in Python,
but I didn't find them so far. (This may also be due to the shortness of
the book). These are:
1.) A 'for'-loop like in Tcl or in C, where you have separate
Init-, condition and increment-blocks, that control the loop.
(Of course, there's while, which can emulate all, but with that,
getting "continue" straight (that is: jump to the "increment-part"
of the body) is probably some hassle ...)
2.) A 'switch'-thing: like a big if-elif-elif-elif-...-else but which
evaluates its expression only once ... and then does all the comparisons.
3.) event-based scripting. (like 'fileevent','after',... in Tcl)
I've read somewhere, that with tkinter I get access to tcl's event-stuff,
But I was more after something that also works without Gui and without
actually using Tcl through Python. Is there a builtin module that
wraps the select() or poll() systemcall, and invokes the registered
functions if "their" respective channel becomes readable/writable
or a timer runs out ?
4.) "calls by reference": maybe I'm totally misunderstanding pythons
function-call-concepts. I want to pass a non-global variable to
a subroutine, have it changed there, and find that variable
changed in the calling context:
def f( x ) : x=42
f(y); print y
of course doesn't work out the way I'm looking for. So what's the
easiest, and (if different) what's the python'iest way to do it ?
(apart from returning a tuple that contains the changed copy of the
during playing around (stress-testing) I created a string object z
that contained 1 MB of zero-characters, then I did the following:
with Python 1.5 I stopped it after an hour, when it still wasn't
finished, whereas in Python 2.2 (on a different, little slower, but
more recently installed) machine this took less than 10 seconds (iirc).
On a third machine (about double fast than the other two) with
Python 2.0 it also seems to take ages.
Is this a bug in old versions, or has something severely changed from
2.0 to 2.2 that affects performance so much ? Or is this just one of
many reasons to upgrade to 2.2.1 on all the machines ?-)
PPS: python'ing on linux I currently am.
Newsflash: Sproingy made it to the ground !
read more ... <http://avl.enemy.org/sproingy/>
More information about the Python-list