Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Possible Duplicate:
How to get/set logical directory path in python

I have a Python script that I run from a symlinked directory, and I call os.getcwd() in it, expecting to get the symlinked path I ran it from. Instead it gives me the "real" path, and in this case that's not helpful. I need it to actually give me the symlinked version.

Does Python have a command for that?

like image 620
Gabriel Hurley Avatar asked Oct 09 '09 09:10

Gabriel Hurley


People also ask

What does the OS Getcwd () method do?

getcwd() method is used to get the current working directory of a process. Somewhere in your script, you can add this function anytime you wish to know or get the directory of an operation currently being carried out.

What is the return value of OS Getcwd ()?

os. getcwd() method tells us the location of current working directory (CWD). Parameter: No parameter is required. Return Value: This method returns a string which represents the current working directory.


1 Answers

Workaround: os.getenv('PWD')

like image 152
richq Avatar answered Oct 03 '22 23:10

richq