classification
Title: pathlib: Allow ellipsis to appear after "/" to navigate to parent path
Type: enhancement Stage: resolved
Components: Library (Lib) Versions:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, pitrou, serhiy.storchaka, steve.dower, tuxtimo, yselivanov
Priority: normal Keywords: patch

Created on 2018-06-01 21:57 by yselivanov, last changed 2018-06-03 02:51 by yselivanov. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 7329 closed yselivanov, 2018-06-01 21:58
Messages (6)
msg318468 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-06-01 21:57
We can allow using ... to navigate the "parent" path:

    >>> import pathlib
    >>> p = pathlib.Path('a/b/c')
    >>> p
    PosixPath('a/b/c')
    >>> p / ...
    PosixPath('a/b')
    >>> p / ... / ... / 'temp'
    PosixPath('a/temp')

The patch is trivial and I think that using "..." instead of ".parent" makes code clearer and cuter.
msg318488 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-02 04:29
Note that 'a/b/c/..' is not the same as 'a/b' if 'c' is a link. And since "p / ..." looks very similar to "p / '..'", it will cause mistakes. "p.parent" is more explicit.

AFAIK in cmd.exe on Windows 'a/b/c/...' means 'a/b/c/../..'. This is yet one source of confusion.
msg318492 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2018-06-02 08:40
I've just tried, "..." doesn't seem to mean anything on the Windows CLI.

But I agree with the reservation that having "..." mean something different than ".." is a recipe for confusion.
msg318495 - (view) Author: Timo Furrer (tuxtimo) * Date: 2018-06-02 10:45
> I've just tried, "..." doesn't seem to mean anything on the Windows CLI.

It's not only about Windows / Linux here - it's about the shell and command which is being used. If we talk about "cd" for example - it's a builtin in most common shells on Linux, which behave differently:

bash:

    /a/b/c $ cd ...
    bash: cd: ...: No such file or directory

dash:

    /a/b/c $ cd ...
    dash: 8: cd: can't cd to ...

zsh:

    /a/b/c $ cd ...
    /a $

I think using '...' to navigate to the parent is confusing. 
It's well known and agreed that '..' is for navigating to the parent. 
'...' looks similar but is definitely not the same as '..' and therefore shouldn't be treated as such.
msg318514 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2018-06-02 20:30
I'm personally not loving the idea either by re-purposing Ellipsis for this since my brain keeps thinking you're trying to go two levels up instead of just one with that extra dot. It should also be mentioned that paths ending in an ellipsis has actual meaning in Perforce when it comes at the end of a path.
msg318519 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-06-03 02:51
Since nobody likes the idea I'm withdrawing the proposal.
History
Date User Action Args
2018-06-03 02:51:26yselivanovsetstatus: open -> closed
resolution: rejected
messages: + msg318519

stage: patch review -> resolved
2018-06-02 20:30:25brett.cannonsetmessages: + msg318514
2018-06-02 10:45:38tuxtimosetnosy: + tuxtimo
messages: + msg318495
2018-06-02 08:40:37pitrousetnosy: + steve.dower
messages: + msg318492
2018-06-02 04:29:46serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg318488
2018-06-01 21:58:48yselivanovsetkeywords: + patch
pull_requests: + pull_request6958
2018-06-01 21:57:15yselivanovcreate