[plug] Python one-liners (was: Sig Code)

Leon Brooks leon at brooks.fdns.net
Sun Mar 4 13:55:49 WST 2001


Michael Hunt wrote:

>> 001   #include <signal.h>
>> 002   #include <time.h>
>> 003   main()
>> 004   {
>> 005       srandom(time(0));
>> 006       for (;;) {
>> 007           int pid = random() % 30000;
>> 008           if (pid > 1 && pid != getpid())
>> 009               kill(pid, random() & 1 ? SIGSTOP : SIGBUS);
>> 010           sleep(10);
>> 011       }
>> 012   }

> Thanks David. Makes a lot more sense when it is formatted nicely. Just
> looking at it on one line like that was twisting my brain. I much more used
> to the nicetys of python than c

Yes, one-liners are kind of hard with Python, given that nesting level 
is determined by the *indenting*...

Try Ruby. Much more fun! Redefine *anything*... I think I'll redefine 
``if'' and see what happens...

-- 
"Windows 95 is a great gift to give your kid this Christmas, because
it will keep your kid fascinated for months trying to get it up and
running and trying to figure out how to use it." -- Scott McNealy, Sun CEO




More information about the plug mailing list