ken wrote: > Hi, > i have a class: > > class LogHandler(ContentHandler): > # a reference to a file open by some other function/class > outputFile;
What do you intend to achieve with this last line, and what's the ';' for? > First, I get an error saying 'NameError: global name 'outputFile' > is not defined' , how can I declare outputFile as a 'file > reference'? If I'm not mistaken it would be best to read the Python tutorial. > Second , how can I set this file reference after I create the > object 'LogHandler'? You shouldn't create an object that has the same name as its class. Anyway, you can open a file using var = file("/path/to/file") > How can I do that? > f = open('dummyFile.txt'); > curHandler = LogHandler() > curHandler.file = f Is it this you want to do? class LogHandler(ContentHandler): pass f = file("dummyfile.txt") curHandler = LogHandler() curHandler.file = f Seems quite pointless to me. I'm still confused about your intentions. Regards, Björn -- BOFH excuse #111: The salesman drove over the CPU board. -- http://mail.python.org/mailman/listinfo/python-list