"massimo s." <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Hi, | | Python 2.4, Kubuntu 6.06. I'm no professional programmer (I am a ph.d. | student in biophysics) but I have a fair knowledge of Python. | | I have a for loop that looks like the following : | | for item in long_list: | foo(item) | | def foo(item): | item.create_blah() #<--this creates item.blah; by doing that it | opens a file and leaves it open until blah.__del__() is called | | Now, what I thought is that if I call | | del(item) | | it will delete item
No, it removes the association between the name 'item' and the object it is currently bound to. In CPython, removing the last such reference will cause the object to be gc'ed. In other implementations, actual deletion may occur later. You probably should close the files directly and arrange code so that you can do so before too many are open. tjr -- http://mail.python.org/mailman/listinfo/python-list