Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Missing pathlib.expanduser()?
-
With this:
import pathlib p = pathlib.Path('~/Documents') p.expanduser()
... I get a stacktrace:
AttributeError: 'PosixPath' object has no attribute 'expanduser'
dir(p)
shows no trace ofexpanduser
, although it should have been there since 3.5.Any ideas why? Something I am doing or A Pythonista quirk?
-
@mikael no error for me....try restart Pythonista
-
@cvp, thanks!
It was a classic case of something having pulled an old version of
pathlib.py
tosite-packages
.Easy to find by checking
pathlib.__file__
.Deleted & restarted & solved.
-
@mikael just wanted to say
print(os.path.dirname(pathlib.__file__))
-
@cvp, I am confused about the added value?
>>> import pathlib >>> pathlib.__file__ '/var/containers/Bundle/Application/B21D36A1-33F6-45D3-8E39-FFD13E200E5D/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/pathlib.py' >>> import os.path >>> os.path.dirname(pathlib.__file__) '/var/containers/Bundle/Application/B21D36A1-33F6-45D3-8E39-FFD13E200E5D/Pythonista3.app/Frameworks/Py3Kit.framework/pylib'
-
@mikael Not a big added value 😀 It shows it is part of Pythonista but if you get a folder like site-packages, it proves you have an unwanted copy