r/learnpython • • May 31 '19

My first Python project: command line application that copies all files with given extension from a directory and its subfolders to another directory showing progress bar and remaining files counter.

This project was inspired by the task from Chapter 9 of Automate the Boring Stuff but I tried to push it a little bit further by adding a possibility of preservation source folder structure, log creation, progress bar, remaining files counter and command line interface.

Here is my code on GitHub.

I am new to programming and GitHub, so any feedback either on the code itself or design of README.md and so on is highly appreciated!

340 Upvotes

47 comments sorted by

View all comments

3

u/apocalipto9 May 31 '19

why did you do

#! python3    

?

3

u/pltnk May 31 '19

Quote from ATBS (link):

The first line of all your Python programs should be a shebang line, which tells your computer that you want Python to execute this program. The shebang line begins with #!, but the rest depends on your operating system.

On Windows, the shebang line is #! python3

5

u/theWyzzerd May 31 '19

I dislike this advice from ATBS because it's simply not true. It works well in your case, but not all python programs will be run from a command line, and not all python programs will run the python3 interpreter on the user's $PATH variable--and, if the user doesn't have python3 in their PATH, it simply won't work.

Shebang is a useful tool for scripts (and not just python, but any script/language that supports command-line execution--bash, perl, ruby, etc) intended to be run in a an environment where the author has control over the environment, but for distributed software I would leave the choice to the person using the tool.

2

u/vampiire May 31 '19

Cant you execute the script directly like python script_name.py?

I thought the shebang only controlled the default interpreter for files that have been made executable.

2

u/theWyzzerd May 31 '19

Yep, you sure can. The # will make the python interpreter treat it as a comment.

2

u/vampiire May 31 '19

but for distributed software I would leave the choice to the person using the tool

i was speaking to this^

if the consumer has an environment that doesnt satisfy the shebang then they are still able to control its execution manually - the shebang will be ignored as a python comment. in your opinion how should distributed software be defined (no shebang, a different shebang)?

2

u/theWyzzerd May 31 '19

I probably wouldn't provide any shebang unless it was intended to be run with a specific interpreter.