Loop Array Given by Python (PySciter) in Sciter/Tiscript

Sciter › Forums › General discussion › Loop Array Given by Python (PySciter) in Sciter/Tiscript

Tagged: , ,

Viewing 2 reply threads
  • Author
    Posts
    • #48022
      joe hartono
      Participant

      I write a python function that return array, the array is python array [(str1, str2, str3), (str1, str2, str3)], and I want to loop it to get every item on array. I have try this:

      
      for (var (a, b, c) in arrayItem) {
          $(#id).append(a);
      } 
      

      But it return integer, not string.

      • This topic was modified 10 years, 1 month ago by joe hartono. Reason: Unclear explaination
    • #48024
      Andrew
      Keymaster

      Pythonic expression (array of tuples):
      tuples = [(str1, str2, str3), (str1, str2, str3)]
      in JS/TS is an array of arrays:
      var tuples = [[str1, str2, str3], [str1, str2, str3]]

      If you want to enumerate first element of each tuple then you should do this:

      for (var tuple in tuples)
          $(#id).append(tuple[0]); // using first element of the tuple
      
    • #48025
      joe hartono
      Participant

      Awesome, thank you mr. Andrew

Viewing 2 reply threads
  • You must be logged in to reply to this topic.