Question for t0mm0 - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32) +--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26) +--- Thread: Question for t0mm0 (/showthread.php?tid=110865) |
Question for t0mm0 - k_zeon - 2011-09-24 How do you use the add_directory with the total_items for the progress bar Code: for url,name in match: - t0mm0 - 2011-09-24 k_zeon Wrote:How do you use the add_directory with the total_items for the progress bar can't really help without knowing what 'match' is and what the error is.... - k_zeon - 2011-09-24 t0mm0 Wrote:can't really help without knowing what 'match' is and what the error is.... Not to worry. got it sorted. another question. How would you exit a for statement. for name in match: if x = 1 then exit for << this is what i would do in VB6 does match have a count ie match(x) that i can check for. still learning. - t0mm0 - 2011-09-24 k_zeon Wrote:Not to worry. got it sorted. you still haven't said what 'match' is or what you are trying to do. can you post some code? python is not (thankfully!) vb6 - you need to think of what it is you are trying to do and then do it in python rather than think of how to do it in vb6 and try and translate, you'll find you end up with neater code that way - k_zeon - 2011-09-24 t0mm0 Wrote:you still haven't said what 'match' is or what you are trying to do. can you post some code? sorry , here is some code. Code: html = net.http_GET(url).content - t0mm0 - 2011-09-24 k_zeon Wrote:sorry , here is some code. ok, cool, so match is a list of tuples and you only want to iterate through the first 5 tuples in the list. python has a cool feature called slices (here is a really good clear explanation) here is an example: Code: import re if you run this you will see the following output: Code: ('http://url1', 'name1', '1901') the nice part is that even if nothing matches you will not get any errors (the code inside the for loop will just not be run at all) also if less than five items are matched, the code in the for loop will only run on each match that does exist and not produce an error. hope that helps! t0mm0 |