Is there a version of os.getcwd() that doesn't dereference symlinks? [duplicate] Is there a version of os.getcwd() that doesn't dereference symlinks? [duplicate] python python

Is there a version of os.getcwd() that doesn't dereference symlinks? [duplicate]


Workaround: os.getenv('PWD')


In general this is not possible. os.getcwd() calls getcwd(3), and according to POSIX.1-2008 (IEEE Std 1003.1-2008):

The pathname shall contain no components that are dot or dot-dot, or are symbolic links.

os.getenv['PWD'] is shell-dependent and will not work for example with sh from FreeBSD.