Thursday, 15 August 2013

Python If/Else Completing If function but not Else

Python If/Else Completing If function but not Else

Having some trouble with an if/else command in which only part of it is
working. When the script is run it will complete the if portion if the
name == check_file, but if it is false it just skips the else statement
and moves to the next task. Here is the portion of the code that isn't
functioning properly:
for name in zip_file_names:
if name == sz_check_file:
if name == sz_check_file:
print name, "Date is 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)
print "sales.xls has been copied."
else:
print "Repoll %s for %s" % (item, business_date_seven)
print "Once information is downloaded press any key."
re_download = raw_input(" ")
ext_ver_cop_seven()
else:
pass
The final else is for the file names that are unzipped that are not needed
for the operation so I have to pass them, but I don't understand why the
if/else inside of that if/else statement isn't functioning properly.
Especially because the if portion is working fine. Thoughts?

No comments:

Post a Comment