This worked for me, but it is definitely hackish and cumbersome. You
basically define the function in a string, exec the string to create
the function, and then use the function interact, instead using the
decoration @interact. (I've read it is frowned up, but...)

# first cell
fields = ['a','b','c','d','e']
init_values = [10,15,31,14,-5, 6]
fields_def = ','.join(['%s=%d' % t for t in zip(fields,init_values)])
fdef= 'def _(' + fields_def + '):\n' \
    + '\tprint sum([' + ','.join(fields) + '])\n'
print fdef   # just to check

# second cell
exec(fdef)
interact(_)

On Thu, Jan 22, 2009 at 9:39 AM, Jonathan Gutow <gu...@uwosh.edu> wrote:
>
> I'm probably being dense here....But would appreciate any suggestions/
> help.  What I want to do is ask students to interactively input a
> variable number of expressions based on some randomly generated
> 'story' problems (actually chemical kinetic mechanisms).  I can
> generate the problems and check them, but cannot figure out how to
> make the @interact construct accept a variable number of
> input_boxes.  Is it possible, and, if so, how?
>
> thanks,
> Jonathan
>
>                          Dr. Jonathan H. Gutow
> Chemistry Department                                 gu...@uwosh.edu
> UW-Oshkosh                                           Office:920-424-1326
> 800 Algoma Boulevard                                 FAX:920-424-2042
> Oshkosh, WI 54901
>                  http://www.uwosh.edu/faculty_staff/gutow/
>
>
>
>
>
> >
>



-- 
"The main things which seem to me important on their own account, and
not merely as means to other things, are knowledge, art, instinctive
happiness, and relations of friendship or affection."
   -Bertrand Russell

L. Felipe Martins
Department of Mathematics
Cleveland State University
luizfelipe.mart...@gmail.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sage-edu" group.
To post to this group, send email to sage-edu@googlegroups.com
To unsubscribe from this group, send email to 
sage-edu+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-edu?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to