On Tue, Jun 05, 2018 at 03:30:35PM +0200, Michel Desmoulin wrote:

> There are very few programs that never use any path operation.

On the contrary, there are many programs than never use any path 
operations. I have many programs which take input and provide output and 
no files are involved at all.

Of course path manipulation is common. But hyperbola about how common it 
is does not help your case.


> Opening a file is such a common one we have a built-in for it with
> open(), but you usually need to do some manipulation to get the file
> path in the first place.
> We have __file__, but the most common usage is to get the parent dir,
> with os or pathlib.

Parent directory of what?

Are you talking about the parent directory of the script? I almost never 
care about the script directory.

I sometimes care about file names passed in by the user, and maybe ten 
percent of the time I care about the parent directory of those file 
names. I sometimes care about the current working directory.

But I can't think of the last time I've cared about __file__. In my 
experience, that's an uncommon need.

You keep making absolute claims about what is "most common". What is 
your evidence for these absolute claims? Have you done a survey of all 
the Python software in existence? Or do what you mean is that this is 
*your* most common usage?

Because it isn't *my* most common usage.


[...]
> So much that pathlib.Path is one of the things I always put in a
> PYTHONSTARTUP since you need it so often.

Please don't speak for me. I don't need it at all, and even if I did, 
putting it in *your* startup file doesn't help me.


> I think Path fits the bill for being a built-in, I feel it's used more
> often than any/all or zip, and maybe enumerate.


This is a quick and dirty survey of my code:

[steve@ando python]$ grep Path *.py */*.py */*/*.py | wc -l
21
[steve@ando python]$ grep "enumerate(" *.py */*.py */*/*.py | wc -l
307
[steve@ando python]$ grep "zip(" *.py */*.py */*/*.py | wc -l
499
[steve@ando python]$ grep "any(" *.py */*.py */*/*.py | wc -l
96
[steve@ando python]$ grep "all(" *.py */*.py */*/*.py | wc -l
224


So I would say that Path is used about 25 times less often than zip, and 
I wouldn't consider zip to be an essential builtin. I use math.sqrt 
about 15 times more often than Path.


> Besides, it would help to make people use it, as I regularly meet dev
> that keep import os.path because of habits, tutorials, books, docs, etc.

Why do you want to *make* people use it? Why shouldn't people use 
os.path if it meets their needs?


-- 
Steve
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to