All python classes do understand the "__del__" destructor.
i.e.:
def __del__ (self):
self.close()
But: In my opinion every predefined python class (like your opened file
object) has a destructor which does reasonable things like closing itself
when the GC destroys the object.
So I think that an opened file whose last reference is gone would be closed
automagically.
Regards,
Mike
---------+---------------------------->
> "Krisztian Kepes"|
> <Kepes.Krisztian@|
> peto.hu> |
> >
> 26.06.2003 13:11 |
> Please respond to|
> wxPython-users |
> >
---------+---------------------------->
>------------------------------------------------------------------------------------------------------------------------------|
> >
> To: <wxPython-users@lists.wxwindows.org> |
> cc: |
> Subject: [wxPython-users] destructor in python ? |
>------------------------------------------------------------------------------------------------------------------------------|
Hi !
Have the any python object with an overrideable destructor ?
exampl.
class fileobj:
def __init(self,filename,access):
self.__file=file(filename,access)
def writelog(self,log):
self.__file.writelines(log)
def close(self)
if self.__file==None: return(0)
self.__file.close()
self.__file=None
like this:
def __done__(self):
self.close()
What the python do with onclosed connections/files ?
ftp=FTP()
ftp.connect(....)
f=file(filename,access)
f.read(....)
The reference is out, ok. But it must run an destructor to the object must
close self owned resources. If it is destroyed without destructor - all of
the resources are remaining in the background !
This is what I don't understand it dotnet too...
Thx:
KK
···
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org