problem with path

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mallikabiswas
    New Member
    • Jun 2008
    • 2

    problem with path

    Hi all,
    I have placed an test.xml file in the folder where I kept my programme(.py file).
    Now when I am going to access this file like
    f=open("test.xm l","r")
    It is giving the error "No such file or directory called test.xml"

    Please help.
    Thanks.
  • kaarthikeyapreyan
    New Member
    • Apr 2007
    • 106

    #2
    Works good for me ...

    karthikeyan@Pre yans-desktop:~/sample$ ls
    test.xml
    karthikeyan@Pre yans-desktop:~/sample$ python
    Code:
    Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42) 
    [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> f=open("test.xml","r")
    >>>
    check for the directory with the command
    Code:
    >>>import os
    >>>os.getpwd()
    ...
    >>>os.listdir('.')
    ['test.xml']
    verify if the file exists there and u are working in the right directory

    Comment

    • Moezzie
      New Member
      • Jun 2007
      • 17

      #3
      Actually i did have the same problem today. The wierd thing was that it only applied to some files in the directory(not all of them). I just made a new directory and put the files in there and voala!...(of corse i changed the path in my script)
      Im not sure what caused it. It would be interesting to know though.

      Comment

      Working...