python - new list for each if -
i have following code:
joblist = self.jobs.findall("job") jitem in joblist: self.deployjobs = [] if jitem.attrib.get("disable") == 'y': self.disablejob = '1' self.effectivedate = currentdate self.deployjobs.append(jitem.text) configxpranddeploy(self) self.deployjobs = [] elif jitem.attrib.get("effective") == nextdate: self.disablejob = '0' self.effectivedate = nextdate self.deployjobs.append(jitem.text) configxpranddeploy(self) self.deployjobs = [] else: self.disablejob = '0' self.effectivedate = currentdate self.deployjobs.append(jitem.text) configxpranddeploy(self) what want each of ifs start clear self.deployjobs can't seem figure out logic.
the problem it's clearing after each part of
ifloop
an if statement not loop. indented code blocks within (technically, "suites" within it) not executed sequentially. 0 or 1 of suites executed per iteration of loop, never more one.
i want list contain in
if, when moveselifempty again
once if or elif condition determined true, suite following that if or elif executed, , entire if-elif-else structure done. execution of if suite never "move elif".
the python language reference describes behavior of if statements clearly.
what want each of
ifs start clearself.deployjobs
assuming mean each want each of if statements suites start clear self.deployjobs, should put self.deployjobs = [] line before if statement... you've done.
so i'm afraid on point have join numerous other posters can't figure out want code do. can suggest, however, ending suites self.deployjobs = [] not helping @ all.
Comments
Post a Comment