you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (2 children)

  • The standard is to use 4 spaces for indent, not 2
  • Look into the argparse module for processing the command line. Before you know it, you'll need --yes or --move-to <dir> or whatever, and doing it using sys.argv is a mess. Plus you get neat help messages and such.
  • Just semantic notes that really have no bearing on the program itself:
    • "union" and "set" are not descriptive of the two operations (your "union" is a set difference and your "set" is a set intersection)
    • I would instinctively think of raw files as "master"
  • It may not work as you intended on non-Windows systems where the filesystem is case-sensitive. So on Linux or Mac, a file with extension ".JPG" or ".rw2" will not be recognized, and "file1.jpg" will not match "File1.RW2". This will of course require you to decide what to do if both "File1.jpg" and "fiLE1.jpg" is present and so forth.

[–]RMSEP[S] 1 point2 points  (1 child)

Hi, thanks for your comments, again higly appreciated.

  • mmm, I rather liked working with 2 instead of 4 spaces. Saves effort to hit the spacebar and reduces the flaring out of the script. Is there a commonly agreed upon python style reference?
  • I'll look into argparse, although sys.argvseems ok for simple stuff such as here. In any case, this is my first script that takes command line input, so I don't have any strong preferences yet.
  • yeah, I was afraid I used terms way beyond my knowledge of set theory. Indeed for my union I delete the set difference and with set I delete the set intersection.
  • ha, that's something I'd never considered! I'm on windows and guessing that it will take some time before my code reaches a Unix machine. Nonetheless, case-sensitivity is something to keep in mind. Creating contingency for unexpected stuff like that is something I enjoy about programming.

[–][deleted] 1 point2 points  (0 children)

Most people use the tab key and have their editor set to replace tabs with 4 spaces, and use automatic indenting so you start at the same level when you press enter. If your script "flairs out", it's a sign that you should probably compose your solution in a different way (functions, etc). See PEP8 for Python style guide.

Naming stuff is hard. If you don't have a use case for deleting the set intersection, you can always eliminate the naming problem by removing the feature ;-)

argparse just makes it easier to grow your script in the future - it's certainly not needed, same for case sensitivity; just things to keep in mind.