Is os.path.expanduser("~/x") equivalent to os.path.abspath(os.path.expanduser("~/x"))?
--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Take control of your privacy with Proton's trusted, Swiss-based, secure services.
Choose what you need and safeguard your digital life:
Mail: https://go.getproton.me/SH1CU
VPN: https://go.getproton.me/SH1DI
Password Manager: https://go.getproton.me/SH1DJ
Drive: https://go.getproton.me/SH1CT
Music by Eric Matyas
https://www.soundimage.org
Track title: Music Box Puzzles
--
Chapters
00:00 Is Os.Path.Expanduser(&Quot;~/X&Quot;) Equivalent To Os.Path.Abspath(Os.Path.Expanduser(&Quot;~/X&Qu
00:27 Accepted Answer Score 6
00:55 Thank you
--
Full question
https://stackoverflow.com/questions/2131...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #path #crossplatform #absolutepath
#avk47
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Take control of your privacy with Proton's trusted, Swiss-based, secure services.
Choose what you need and safeguard your digital life:
Mail: https://go.getproton.me/SH1CU
VPN: https://go.getproton.me/SH1DI
Password Manager: https://go.getproton.me/SH1DJ
Drive: https://go.getproton.me/SH1CT
Music by Eric Matyas
https://www.soundimage.org
Track title: Music Box Puzzles
--
Chapters
00:00 Is Os.Path.Expanduser(&Quot;~/X&Quot;) Equivalent To Os.Path.Abspath(Os.Path.Expanduser(&Quot;~/X&Qu
00:27 Accepted Answer Score 6
00:55 Thank you
--
Full question
https://stackoverflow.com/questions/2131...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #path #crossplatform #absolutepath
#avk47
ACCEPTED ANSWER
Score 6
It depends on what your $HOME points to. On most properly set-up systems (every mainstream Linux distro, OSX and Windows) it'll point to an absolute path, e.g. /home/user or C:/Users/User. But if it's unset, improperly set or even changed manually (export HOME=.), expanduser may result in a relative path, in which case abspath will further change it.
But for most intents and purposes, you can assume that yes, both expressions are equivalent.