April 1st, 2005, 02:51 PM
Originally Posted by pylon
Ok, I did what you suggested with replacing "./" with "/"
and the result:
I thought if you wanted to create a new file/folder, you could just tell it to write to that directory/file and it would create it if it didn't already exist.
You don't have to rush it, its not like it'll be the end of the world if I don't get it, but I'd like to see a simple example sometime
I also took care of the 'self' problem.
Also, one more of those __ thingys, what's __init__ ?
Preceding a path with a / means the root directory on *nix systems, I'm not sure how Windows handles this but it's probably not a good idea to use it. Instead you should remove the / and ./ characters from your filenames entirely.
This means that the line file=open("/element/"+ename+".txt",'w')
will become file=open("element/"+ename+".txt",'w')
Note: that it isn't a good idea to use the names of Pythons built-in functions for your own variables.
__init__ is the method that is called when you create an instance of an object, so it allows you to set default values for instance variables. Basically this is used to set up or "initialize" the instance
programming language development: www.netytan.com – Hula