This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author victorg
Recipients akira, barry, mdk, pitrou, r.david.murray, thejcannon, victorg
Date 2020-03-04.08:13:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1583309596.87.0.762581058148.issue21041@roundup.psfhosted.org>
In-reply-to
Content
Allow negative indexes that could be usefull. 

Example: to compare 2 or more Path, if they come from the same top directory

from pathlib import Path
a = Path("/a/testpy/cpython/config.log")
b = Path("/b/testpy/cpython/config.log")
c = Path("/a/otherfolder/text.txt")
print(f"a.parents[-2] == b.parents[-2] -> {a.parents[-2] == b.parents[-2]}") # False
print(f"a.parents[-2] == c.parents[-2] -> {a.parents[-2] == c.parents[-2]}") # True 
# index = -2 because -1 is "/"
History
Date User Action Args
2020-03-04 08:13:16victorgsetrecipients: + victorg, barry, pitrou, r.david.murray, akira, mdk, thejcannon
2020-03-04 08:13:16victorgsetmessageid: <1583309596.87.0.762581058148.issue21041@roundup.psfhosted.org>
2020-03-04 08:13:16victorglinkissue21041 messages
2020-03-04 08:13:16victorgcreate