[Tutor] Problems with changing directory.

David Holland davholla2002 at yahoo.co.uk
Sun Aug 22 16:45:54 CEST 2004


As part of my studies in my python I have been trying
to write a program that will go to a directory and
search all the files :-
This is the code :-

def change_dir():
    y = '/home/david/Documents/pyprogamming/test/'
    try:
        os.chdir(y)
        print "line 53"
        list_of_files = os.listdir(y)
        print "line 55"
        for file in list_of_files:
            print "line 57"
            linesone = open_files(file)
            getlineinfo(linesone)
            print file
        print "Directory", y,"does exist"
    except:
        print y, "does not exist"


However despite the fact that :-
a) I have imported os
b) The directory exists
I get the message :-
'/home/david/Documents/pyprogamming/test/ does not
exist'
However it does ?
Can any one help ?


	
	
		
___________________________________________________________ALL-NEW Yahoo! Messenger - all new features - even more fun!  http://uk.messenger.yahoo.com


More information about the Tutor mailing list