Alex if you have any patience left please look at this
M. Clift
noone at here.com
Tue Oct 5 12:29:55 EDT 2004
Hi Alex,
I can't get this to run. Could you help?
import random
sequence = ['item1','item2','item1']
previous = None
def weird_appender(sequence):
first_time_choices = {'item1': 'abc', 'item2': 'def', }
choices = { None: first_time_choices,
'item1': {'item1': 'blu', 'item2': 'ghi', },
'item2': {'item1': 'jkm', 'item2': 'nop', }
}
previous = None
d = choices.get(previous, first_time_choices)
choose = d.get(item, [''])
previous = item + random.choice(choose)
yield previous
print list(weird_appender(sequence))
# yield item + random.choice(choose)
# previous = item
# previous = item + random.choice(choose)
# yield previous
Thanks,
Malcolm
More information about the Python-list
mailing list