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 <>
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 "/"
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: <>
2020-03-04 08:13:16victorglinkissue21041 messages
2020-03-04 08:13:16victorgcreate