Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6206631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:29:01+00:00 2026-05-24T05:29:01+00:00

According to http://docs.python.org/library/os.path.html On Windows, there is a current directory for each drive This

  • 0

According to http://docs.python.org/library/os.path.html

“On Windows, there is a current directory for each drive”

This is giving me some trouble when I use os.getcwd() on Windows.

I am using Python 2.7 on my C drive to call a script located on the shared network drive F:. Yet, os.getcwd() from within this script is returning a directory on my C drive.

Is there anything I can do to get the working directory for my F drive?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:29:02+00:00Added an answer on May 24, 2026 at 5:29 am

    Actually, it depends:

    If Python is started directly (not going through cmd.exe), then yes, you only have the one current directory (it’s like always specifying cd /d …):

    --> import os
    --> os.getcwd()
    'c:\\source\\dbf-dev'
    --> os.chdir('z:')
    --> os.getcwd()
    'Z:\\'
    --> os.chdir('c:')    # assumes root directory
    --> os.getcwd()
    'C:\\'
    

    But, if you start Python from cmd.exe, you get the historical perspective:

    >>> import os
    >>> os.getcwd()
    'Z:\\perm-c'
    >>> os.chdir('c:')    # does not assume root directory
    >>> os.getcwd()
    'C:\\Source\\Path'
    >>> os.chdir('d:')
    >>> os.getcwd()
    'D:\\'
    >>> os.chdir('l:')
    >>> os.getcwd()
    'L:\\'
    >>> os.chdir('l:\\letter')
    >>> os.getcwd()
    'l:\\letter'
    >>> os.chdir('z:')
    >>> os.getcwd()
    'Z:\\perm-c'
    >>> os.chdir('l:\\')
    >>> os.getcwd()
    'l:\\'
    

    Undoubtedly this is an artifact of cmd.exe doing its thing behind the scenes.

    To answer your original question, though — the only way to find out the current directory on drive f: is

    • 1) to have started Python from cmd.exe
    • 2) os.chdir() to ‘f:’
    • 3) os.getcwd()
    • 4) os.chdir() back (if desired)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to http://docs.python.org/dev/library/plistlib.html , plistlib is available to non-Mac platforms only since 2.6, but
In the python documentation for struct, the word buffer is used without explanation: http://docs.python.org/library/struct.html
Using this example from http://docs.python.org/tutorial/classes.html#class-objects : class MyClass: A simple example class i =
According to this site: http://httpd.apache.org/docs/2.2/howto/access.html I need to use something like the script below
According to http://www.faqs.org/docs/diveintopython/fileinfo_private.html : Like most languages, Python has the concept of private elements:
According to this http://perldoc.perl.org/UNIVERSAL.html I shouldn't use UNIVERSAL::isa() and should instead use $obj->isa() or
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html According to that article STL isn't suited for game-development. What are your thoughts
According to this http://docs.nuget.org/docs/start-here/using-the-package-manager-console I should see the PM prompt and commands like get-packages
According to http://msdn.microsoft.com/en-us/library/aa916070.aspx (DnsQuery_W), DNS query libraries are available on Windows Mobile / CE
According to this http://www.cplusplus.com/reference/clibrary/csignal/signal.html SIGINT is generally used/cause by the user. How do i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.