Python If/Else Completing If function but not Else -


having trouble if/else command in part of working. when script run complete if portion if name == check_file, if false skips else statement , moves next task. here portion of code isn't functioning properly:

    name in zip_file_names:         copy_to = copy_this.get(name)         if copy_to not none:             source_file = os.path.join(r'\\svr-dc\ftp site\%s\daily' % item, name)             destination = os.path.join(r"c:\%s" % item, copy_to)             shutil.copy(source_file, destination)             print name, "has been verified , copied."         elif copy_to not none:             print "%s has been completed." % item         else:             print "repoll %s %s" % (item, business_date_one)             print "once information downloaded press key."             re_download = raw_input(" ")             ext_ver_cop_one() 

the final else file names unzipped not needed operation have pass them, don't understand why if/else inside of if/else statement isn't functioning properly. because if portion working fine. thoughts?

if first if evaluating true (i.e., reach inner if @ all), second 1 automatically evaluate true, since it's exact same condition.

you'll want remove outer if, else: pass @ end of loop doesn't anything. iteration finish executing, anyway (unless there's more loop after code block).

after further discussion, sounds want this:

for name in zip_file_names:     if name == sz_check_file:         print name, "date verified."         source_file = os.path.join(r'\\svr-dc\ftp site\%s\daily' % item, sz_check_file)         destination = os.path.join(r"c:\%s" % item, 'sales.xls')         shutil.copy(source_file, destination)         shutil.copy(source_file, r"c:\%s" % item)         sz_found = true #flag sz found         print "sales.xls has been copied."     elif name == sc_check_file:         print name, "date verified."         source_file = os.path.join(r'\\svr-dc\ftp site\%s\daily' % item, sc_check_file)         destination = os.path.join(r"c:\%s" % item, 'cosales.xls')         shutil.copy(source_file, destination)         shutil.copy(source_file, r"c:\%s" % item)         sc_found = true #flag sc found         print "cosales.xls has been copied." #check flags ensure files found if !(sz_found&&sc_found):     print "repoll %s %s" % (item, business_date_seven)     print "once information downloaded press key."     re_download = raw_input(" ")     ext_ver_cop_seven() 

i added flags different files - said 4, you'll need extend idea check others. might find method of setting flags that's more extensible if add files copy, that's general idea. keep track in loop of you've found, , check after loop whether found need.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -