I wrote the birth announcement for my daughter, Ariana, in the Python
ProgrammingLanguage? for the amusement of my
ComputerGeek friends. Note that this is a real program, and gives the time of her birth in the time zone of the person running the program. It is also technically correct in that the variable
name really
does live in different address spaces in the parent and child processes. Yeah, I'm a dork.
#!/usr/bin/python
# This program forks(). That should be plenty for a few years' entertainment
# Copyright (C) 2003 Kirk & Jennifer Strauser
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# However, the output of this particular instance shall remain
# exclusively licensed to the authors for a period of up to eighteen
# years.
# $Id: BirthAnnouncement.txt,v 1.2 2003/11/22 17:26:00 KirkStrauser Exp kirk $
import time
import os
eta = 1049547660
name = "Jennifer Strauser"
if eta > time.time():
# Not done yet
time.sleep(eta - time.time())
pid = os.fork()
if pid:
print "%s: At %s, I got my own address space back!" % (name, time.ctime(eta))
else:
length = 20.5 # inches
weight = 5.4 # pounds.ounces
name = "Ariana Nicole Strauser"
print "%s: Hello, world!" % name
--
KirkStrauser - 08 Apr 2003
Computing.BirthAnnouncement moved from Main.BirthAnnouncement on 22 Nov 2003 - 17:24 by KirkStrauser -
put it back