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/MNKRQF3ZM77A224EO5OZLLAUFGB5MTVA/#OH4ANXJTTTKONQ4FRWDTEW2FEZVSKLZV 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 _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/EECQKGFY552ISAAJKB2HFEDMRT7VOZXX/ Code of Conduct: http://python.org/psf/codeofconduct/