Thread: open() path

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    12
    Rep Power
    0

    Question open() path


    Hi, i know it isnt possable to redefine the built-in open function, is there a way to tell it where to look so u dont have to enter the whole path? ie.

    I have a script in c:\python_scripts and i want to access files in the apache htdocs directory (c:\apache\htdocs\).

    Thanks in advance
    Tom
    Last edited by calorics; September 17th, 2003 at 06:45 PM.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    383
    Rep Power
    13

    Re: open() path


    Originally posted by calorics
    Hi, i know it isnt possable to redefine the built-in open function, is there a way to tell it where to look so u dont have to enter the whole path? ie.

    I have a script in c:\python_scripts and i want to access files in the apache htdocs directory (c:\apache\htdocs\).

    Thanks in advance
    Tytan
    I think it's sys.path.append("/some/path/here"), but I'm not sure that's the path that it uses (I know that it uses that for python modules, ie, the PYTHONPATH).

    But also, in 2.2 and later it's file() and not open()
    Debian - because life's too short for worrying.
    Best. (Python.) IRC bot. ever.
  4. #3
  5. Wacky hack
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2001
    Location
    London, England
    Posts
    513
    Rep Power
    14
    You could always just make your own function to fake it for you, by taking the path (image.jpg) and appending it to your prefix (/wherver/you/want) so you can just call myopen("image.jpg") and it will do it for you.

IMN logo majestic logo threadwatch logo seochat tools logo