Re: Python's "only one way to do it" philosophy isn't good?



Michele Simionato <michele.simionato@xxxxxxxxx> writes:

Right. So? I understand this issue completely and I code
accordingly.

What does it mean you 'code accordingly'? IMO the only clean way out
of this issue is to NOT rely on the garbage collector and to manage
resource deallocation explicitely, not implicitely.

(1) I don't rely on the refcounter for resources that ABSOLUTELY,
POSITIVELY must be freed before the scope is left. In the code that
I've worked on, only a small fraction of resources would fall into
this category. Open files, for instance, rarely do. For open files,
in fact, I actually want access to them in the traceback for debugging
purposes, so closing them using "with" would be the opposite of what I
want.

(2) I don't squirrel away references to tracebacks.

(3) If a procedure catches an exception but isn't going to return
quickly, I clear the exception.

|>oug
.



Relevant Pages

  • Re: garbage collection of open resources
    ... > Eventually you might run out of resources. ... > The GC does dispose of all objects eventually, and even if you set the ... >>Everything I have read suggests that if I open files or database ... >>Obviously I know that there are several reasons for closing the resources ...
    (microsoft.public.dotnet.languages.csharp)
  • garbage collection of open resources
    ... Everything I have read suggests that if I open files or database connections ... My question is - could data corruption occur to any open data sources that ... simply means that those open resources will simply be locked ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: maximum number of threads
    ... Gabriel Genellina wrote: ... as you can't have 10000 open files at once. ... resources are not infinite. ...
    (comp.lang.python)
  • Re: maximum number of threads
    ... Gabriel Genellina wrote: ... as you can't have 10000 open files at once. ... resources are not infinite. ...
    (comp.lang.python)
  • Re: Try Finally...
    ... Now we can protect every more or less specialized action ... an error indication (exception or error code) has to be ... an according exception handler can be inserted into the code. ... resources, as they are related to specific actions. ...
    (comp.lang.pascal.delphi.misc)