I'm coming from Tcl-world ...

Keith Dart kdart at kdart.com
Sat Aug 3 06:24:01 EDT 2002


In article <slrnakleti.c05.Andreas.Leitgeb at pc7499.gud.siemens.at>,
"Andreas Leitgeb" <Andreas.Leitgeb at siemens.at> penned these words:

>> 3.) event-based scripting. (like 'fileevent','after',... in Tcl)
> [common answer: yes, there are modules: asyncore and select] Thanks a
> lot, I'll have a look at them.

YOu might also want to look at the asyncio module in the pyNMS package.

http://pynms.sourceforge.net/

This works like asyncore, but uses SIGIO. It only works on Linux,
however. And it needs a little more work....


> 
>> 4.) "calls by reference":
>>      def f( x ) : x=42
> [common answer: use mutable containers instead, e.g.: ] [  def f(x):
> x[0]=42    ]
> [  x= a list, containing my object as first (and perhaps only) element 
> ] [  f(x);     then,  x[0] outside of f is  still 42 ] It's not exactly
> what I fancied, but near enough :-)

I usually use an idiom like the following:

def inc(x):
	return x+1

x = 1
x = inc(x)
x = inc(x)
etc...

That is, the function just returns the new value, and you reassign the
name. although, for this simple example, that is unnecessary snd slower.


--                           ^
                           \/ \/
                           (O O)
-- --------------------oOOo~(_)~oOOo----------------------------------------
Keith Dart
<mailto:kdart at kdart.com> 
<http://www.kdart.com/>  
----------------------------------------------------------------------------
Public key ID: B08B9D2C Public key: <http://www.kdart.com/~kdart/public.key>
============================================================================



More information about the Python-list mailing list