[Tutor] optimize code

Kent Johnson kent37 at tds.net
Tue Dec 30 23:23:42 CET 2008

On Tue, Dec 30, 2008 at 3:42 PM, Norman Khine <norman at khine.net> wrote:
> Hi,
> I have an updated version at http://paste.lisp.org/display/72843
> Thanks for the advice, the code is much smaller and leaner than the first
> attempt.

The level2-4 code could all be consolidated into a loop:

for levelName in 'level2 level3 level4'.split():
  level = context.get_form_value(levelName)
  if level is None: break
  title = '%s: %s' % (title, level)


More information about the Tutor mailing list