Jonathan wrote:
> Thanks, this looks like it might do what I want. I have some
> questions for below on exactly what you are doing.
>
> On Jan 22, 10:30 am, Luiz Felipe Martins
> <[email protected]> wrote:
>
>> 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)])
>>
> What is the zip(...) doing? Does this change the type of the values
> or is it a sneaky way of
> indexing both values at once?
>
zip is just a way of combining two lists, element-wise:
sage: zip([1,2,3],[4,5,6])
[(1, 4), (2, 5), (3, 6)]
sage: zip?
Type: builtin_function_or_method
Base Class: <type 'builtin_function_or_method'>
String Form: <built-in function zip>
Namespace: Python builtin
Docstring:
zip(seq1 [, seq2 [...]]) -> [(seq1[0], seq2[0] ...), (...)]
Return a list of tuples, where each tuple contains the i-th element
from each of the argument sequences. The returned list is truncated
in length to the length of the shortest argument sequence.
Class Docstring:
<attribute '__doc__' of 'builtin_function_or_method' objects>
Jason
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sage-edu" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-edu?hl=en
-~----------~----~----~----~------~----~------~--~---