Results 1 to 6 of 6

Thread: [Python] os.listdir(DIR) Problem

  1. #1
    Join Date
    Mar 2007
    Location
    #
    Beans
    737

    [Python] os.listdir(DIR) Problem

    #
    Last edited by regomodo; January 23rd, 2010 at 09:14 PM.
    Is this for enhancing your E-peen?

  2. #2
    Join Date
    Sep 2006
    Beans
    2,914

    Re: [Python] os.listdir(DIR) Problem

    even though you have listed out the directory information using os.listdir(), however, if you are doing further processing , you should change directory to that directory first, using os.chdir()

  3. #3
    Join Date
    Mar 2007
    Location
    #
    Beans
    737

    Re: [Python] os.listdir(DIR) Problem

    #
    Last edited by regomodo; January 23rd, 2010 at 09:13 PM.
    Is this for enhancing your E-peen?

  4. #4
    WW is offline Iced Blended Vanilla Crème Ubuntu
    Join Date
    Oct 2004
    Beans
    1,532

    Re: [Python] os.listdir(DIR) Problem

    That's strange--look at the traceback. It says the bad line is
    files = os.listdir(dir_now)
    but there is no such line in your code. Are you sure it was the latest version of your file in which the problem occurred?

  5. #5
    Join Date
    Mar 2007
    Location
    #
    Beans
    737

    Re: [Python] os.listdir(DIR) Problem

    #
    Last edited by regomodo; January 23rd, 2010 at 09:13 PM.
    Is this for enhancing your E-peen?

  6. #6
    WW is offline Iced Blended Vanilla Crème Ubuntu
    Join Date
    Oct 2004
    Beans
    1,532

    Re: [Python] os.listdir(DIR) Problem

    OK, but now I don't understand how ghostdog74's suggestion fixed your problem. The error was definitely with os.listdir(...) (and not some subsequent command), and you gave apparently give it a full path name (that's what the traceback shows), so why should os.chdir(...) have any effect?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •