Hi All, The pathlib library is really helpful when working with paths, but creating an instance of Path class could be easier. There was a discussion about solving this with p-strings here https://mail.python.org/archives/list/python-ideas@python.org/thread/MNKRQF3... But that would alter python syntax. Easier, but just as nice solution could be adding the following snippet to pathlib: class PathLiteral(): def __truediv__(self, other): return Path(other) path_literal = PathLiteral() This would allow the following snippet to work:
from pathlib import path_literal as p p/"foo" PosixPath('foo')
This idea is inspired by this tweet https://twitter.com/bitecode_dev/status/1217429169396731906 The core of the idea is that it does not require syntax changes, only need a small instance of an object, that can simplify and encourage use of pathlib. When someone needs to rewrite a lots of string-paths to pathlib's Path you only need to add that import line, and prepend strings with "p/". Cheers, MM