move up a level

Manuel Kaufmann humitos at gmail.com
Tue Nov 21 10:31:13 EST 2006


El Martes, 21 de Noviembre de 2006 03:07, rplobue at yahoo.com escribió:
> alright, noob question: i want to open a file in a directory above the
> current one i'm in.  I'm trying to use myfile =
> open('../thefileiwant.txt', 'r')  but the ../ doesn't work.  How do i
> do it?

Hello, I proved your doubt in my PC and it works fine. This is the example:

Python 2.4.4c1 (#2, Oct 11 2006, 21:51:02)
[GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.getcwd()
'/home/manuel/descargas'
>>> file = open('../proof.py')
>>> print file.read()
import sys
if __name__ == '__main__':
        print 'manuel'

>>>

-- 
Kaufmann Manuel



More information about the Python-list mailing list