First page Back Continue Last page Overview Image

Lösung, Teil 1

import os

def child(pipeout):

bottles = 99

bob = "bottles of beer"

otw = "on the wall"

take1 = "Take one down and pass it around"

store = "Go to the store and buy some more"

while True:

if bottles > 0:

values = (bottles, bob, otw, bottles, bob, take1, bottles - 1,bob,otw)

verse = "%2d %s %s,\n%2d %s.\n%s,\n%2d %s %s.\n" % values

#os.write(pipeout, verse) # Python2.x

os.write(pipeout, bytes(verse, "ascii"))

bottles -= 1

else:

values = (bob, otw, bob, store, bottles, bob,otw)

verse = "No more %s %s,\nno more %s.\n%s,\n%2d %s %s.\n" % values

os.write(pipeout, bytes(verse, "ascii"))

bottles = 99