Ken Tilton wrote: > pps. How would Python do this?
Here's one way it could look: defskill("absolute-value", title = "Absolute Value", annotations = [ "Take the absolute value of #op#.", "The vertical bars around #op# mean 'the absolute value of' #op#.", "Absolute value of #strn# is the 'distance' of #strn# from zero.", "Absolute value is always zero or positive: #str|n|=n#, and #str|-n|=n#." ], hints = [ "What do those vertical bars around #op# mean?", "Have you learned about 'absolute value'?", """Absolute value can be thought of as the 'distance' of a value from zero on the number line, and distance is always positive.""", "The rule is:#str|-n|=|n|##str=n#. Can you apply that to #op#?", "Some examples: #str|+42|=42#, #str|-42|=42#, and #str|0|=0#.", """To get the absolute value of a number such as #op#, we simply drop any minus sign.""" ] ) > Is it possible to avoid committing to an > implementation mechanism? The defskill function could do just about anything with this. Here's one possibility: skills = {} class Skill: pass # fill in whatever methods you need here def defskill(name, title, annotations, hints): skill = Skill() skill.title = title skill.annotations = annotations skill.hints = hints skills[name] = skill This gives you a dictionary of Skill instances indexed by name, each one having a title and lists of annotation and hint strings. The rest of the system can process this however required. -- Greg -- http://mail.python.org/mailman/listinfo/python-list