jira - python -- for with an if statement -


I do not understand that when I run my code, if statement is not run for each statement is. Even when found that the number is greater than 0! Def findpattern (commit_msg): pattern = re.compile ("\ w \ w * - \ d \ d *") group = pattern. Opaque (commit_msg) found = getIterLength (group) Get printed if found & gt; 0: Issues for the match in the group = print: printed "print-matched issues:" auth = soap.login (jirauser, passwd) print match.group (0) getIssue (auth, match.group (0)) issues = Issues + 1 other: sys.exit ("no issue was found.") "Retrieved issue:" + str (issues)

Any help would be appreciated, I I'm peating my head over it for an hour.

Your getIterLength () searching for function length Tired of the Iterator returned by finder () . You will then need a new iterator instance for the loop. Instead, I will resume your code like this:

  def findpattern (commit_msg): pattern = re.compile ("\ w \ w * - \ d \ d *") group = Found for matlar = 0 points = 0: print "print-matched issues:" auth = soap.login (jirauser, passwd) print match.group (0) getIssue (auth, match.group (0) ) Issues = issues found + 1 + = 1 if found == 0: sys.exit ("No issue pattern found.") Print "Recovered issues:" + str (issues)  

Or, you findall () instead of finditer () (Which is an Iterator, is not an Iterator) which you use to get the LAN (group) shape and then repeat it in its loop again.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -