Why is Python popular, while Lisp and Scheme aren't?

Louis M. Pecora pecora at anvil.nrl.navy.mil
Mon Nov 18 13:59:45 EST 2002


In article <aqsn4t$6h2$3 at solaris.cc.vt.edu>, Carl Banks
<imbosol at vt.edu> wrote:

> The idiom you speak of is common enough.
> 
> do_A()
> if test_based_on_A():
>     take_action_A()
> else:
>     do_B()
>     if test_based_on_B():
>         take_action_B()
>     else:
>         do_C()
>         if test_based_in_C():
>             take_action_C()
>         else:
>             ...
> 

Off the top of my head (and I am not a prof.programmer or python guru)
why not use lists?

# Make lists of the functions

dolist=[do_A, do_B, do_C, ...]
testlist=[test_based_on_A, test_based_on_B, test_based_on_C,...]
actionlist=[take_action_A, take_action_B, take_action_C, ...]

# Do the lists until happy
i=0
for f in do list:
   f()
   if testlist[i]():
      actionlist[i]()
      break

Won't that or something else like it do it?  Eliminate the nesting?

-- 
Lou Pecora
  - My views are my own.



More information about the Python-list mailing list