Current drive and directory

Fredrik Lundh fredrik at pythonware.com
Wed May 26 17:37:56 EDT 2004


"EAS" wrote:
> Does anyone know how to display the current directory using DOS
> and/or Python? I already tried os.pardir and os.curdir in Python, but all
> they return are a couple of periods...

did you read the fine documentation?  look under "files and
directories":

    http://docs.python.org/lib/os-file-dir.html

    os.getcwd() returns the drive/path.

    you can use os.path.splitdrive(os.getcwd()) to get the drive
    and the path as two separate strings.

curdir etc is documented a little later in the same chapter:

    http://docs.python.org/lib/os-path.html

</F>







More information about the Python-list mailing list