Does os.getcwd() and os.curdir have the same effect ?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Sep 9 09:38:16 EDT 2012


On Sun, 09 Sep 2012 06:22:09 -0700, iMath wrote:

> Does os.getcwd() and os.curdir have the same effect ?

You could answer that yourself with two seconds experimentation at the 
interactive prompt.


py> os.getcwd()
'/home/steve'
py> os.curdir
'.'

For more information, you can try reading the Fine Manual:

http://docs.python.org/library/os.html#os.getcwd

http://docs.python.org/library/os.html#os.curdir


In case it isn't obvious: no, they are completely different. os.getcwd is 
a function which returns the path of the current working directory. 
os.curdir is a string which the operating system will understand to mean 
"this directory".



-- 
Steven



More information about the Python-list mailing list