[issue33301] Add __contains__ to pathlib

Serhiy Storchaka report at bugs.python.org
Tue Jun 19 23:57:27 EDT 2018


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

There was a similar (closed) issue about making Path an iterable. The problem with both these related ideas is that they are ambiguous. Does it means that a directory contains a specified file, or that a path contains a specified path component, or that a specified path is a prefix of other path? There are third-party pathlib-like implementations that make Path a str subclass. They have both __iter__ and __contains__ inherited from str, but with different meaning.

I'm -1. It is better to write explicitly what you mean than allow the computer to guess.

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33301>
_______________________________________


More information about the Python-bugs-list mailing list