why do you do:
?Code:while (1==1)
Why not just while (1) ? or while (true)?
I was pleasantly surprised![]()
why do you do:
?Code:while (1==1)
Why not just while (1) ? or while (true)?
Because I've been doing a lot of programming on my calculator lately, and any while loop conditions must be in the form of A=B where A and B are either variables or numbers. It never occured to me that I could do "while 1"...Why not just while (1) ? or while (true)?
It doesn't matter, though, because it's still really easy to trap signals in perl![]()
J'ai patenté ça.
Code:#!/usr/bin/env python import signal, time, os def got_sig(*args): print "Hey! I got the %d signal!" % args[0] # You can also use numbers signal.signal(signal.SIGTERM, got_sig) signal.signal(signal.SIGSEGV, got_sig) while 1: print "Good day for %d to be alive" % os.getpid() time.sleep(10) # I used this so that my CPU wasn't at 100%
I think it's funny that Python needs a whole function to find it's own PID![]()
I think it's just bright to seperate things into modules. *Since the PID is an os thing, might as well put it in the os module. *This just adds to the clarity of the whole program. Anyway, $$ is just an alias to a function.
'I think it's funny that Python needs a whole function to find it's own PID![]()
As does Perl. What do you think $$ does? I find it funny that in Python it's easy to see which commands are functions and in Perl you get magical little operators that perform functions when you may not realize it.
How's that? The way I understand it is that $$ is a scalar variable, just like every other variable that starts with '$'. $$ stores the pid, $0 stores the name of the program, etc etc.Anyway, $$ is just an alias to a function.
If you really hate them, you can just use English; and then you get variables with actual names, but that slows down the script.
I would guess ( I couldn't find anything in the source code, but the thing is so messed up I'm not surprised) that when perl starts, it calls functions (getpid, getuid, getgid, etc.) from a module (probably a C module) and stores these values in $ variables.
How's that? The way I understand it is that $$ is a scalar variable, just like every other variable that starts with '$'. $$ stores the pid, $0 stores the name of the program, etc etc.
Bookmarks