> -----Original Message-----
> From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On
> Behalf Of Peter Otten
> Sent: Wednesday, August 12, 2015 2:22 AM
> To: tutor@python.org
> Subject: Re: [Tutor] a few question about my evolving program
> 
> Clayton Kirkwood wrote:
> 
> 
> > Look here:
> 
> After some clean-up:
> 
> >     if current_filename in target_directory_file_list:
> >        current_stat_info = os.stat(
> >            current_directory_path + '/' + current_filename,
> >            follow_symlinks=False)
> >        current_file_size = current_stat_info.st_size
> >        if current_file_size == target_filename_size[current_filename]:
> >            print(
> >                "file", current_filename,
> >                "size:", current_file_size,
> >                "found in both current_directory_path",
> >                current_directory_path,
> >                "and", target_directory, "\n")
> >            duplicate_files =+ 1
> >        else:
> >            print("file ", current_filename, " not a duplicate\n")
> 
> > As you can see the current_filename does not exist in
> > target_directory_file list. Yet, I fall through to the next line. Yes,
> > the indents are all fine: I wouldn't have gotten to running code
> > otherwise.
> 
> Ah, the old adage "If it compiles it's done" ;)
> 
> > I turned my head upside
> > down and still couldn't see why it doesn't work and what I am missing?
> 
> I'm not completely sure what you are expecting. If you want to print
> 
> file somefile.jpg not a duplicate
> 
> for files not in the target_directory_file_list you need another else for
the
> outer if
> 
> >     if current_filename in target_directory_file_list:
> >        current_stat_info = os.stat(
> >            current_directory_path + '/' + current_filename,
> >            follow_symlinks=False)
> >        current_file_size = current_stat_info.st_size
> >        if current_file_size == target_filename_size[current_filename]:
> >            print(
> >                "file", current_filename,
> >                "size: ", current_file_size,
> >                "found in both current_directory_path",
> >                current_directory_path,
> >                "and", target_directory, "\n")
> >            duplicate_files =+ 1
>          else:
>              print("file", current_filename,
>                    "not a duplicate (different size)")
>      else:
>          print("file ", current_filename,
>                "not a duplicate (not in target directory)")

I think actually that the outer else is not necessary, because at this point
the inner else's print is just to verify that the same filename may exist in
both directories' being compared, but that their file sizes are different
therefore the files are different and I won't want to delete the target
directory file.
crk

> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to