Order of constructor/destructor invocation

Reginald B. Charney news at charneyday.com
Tue Mar 5 14:32:01 EST 2002


Brett is exactly right. I am using an approach that is valid and elegant in
C++. Since I am fairly new to Python, I had assumed it handled
contructors/destructors in an ordered (i.e. deterministic) fashion. It seems
not.

While Justin is correct - there are a number of packages out there to
generate HTML, I was writing an article and trying to use Python for the
simple examples in the article. (The article was not about Python, per se).
I had to remove all references to Python when I found that the order of
destruction was non-deterministic.

As an aside, it seems a shame that while algorithms are often implementation
independent, their actual coding varies widely because of language
semantics. For example, I expect all computer languages to have a looping
construct, a way of doing arithmetic, and a way of testing for ordering. In
OO languages, I expect a way of defining classes, instantiating them,
defining inheritance and polymorhism, etc. It is interesting that
destruction/garbage collection (something usually done after everything has
been completed) has so profound effect on the design of programs and thus,
implementation of algorithms.

Reg.

"Brett g Porter" <BgPorter at NOartlogicSPAM.com> wrote in message
news:Rt8h8.111896$7a1.9472757 at bin5.nnrp.aus1.giganews.com...
>
> "Justin Sheehy" <justin at iago.org> wrote in message
> news:mailman.1015350430.26774.python-list at python.org...
> > "Reginald B. Charney" <news at charneyday.com> writes:
> >
>
> > Perhaps you are using "destructors" to refer to some concept that is
> > different from what the rest of us use that word for?
> No, based on what he wants to do (and his observation that Python suffers
> from the same 'misdesign' as Java) it's pretty clear that he's using
> 'destructor' in the C++ sense, since C++ dtors have exactly the behavior
> he's looking for.
>
> As someone who needed a year or so to separate the C++ and Python halves
of
> my brain, I sympathize, and can only urge (as gently as possible) Mr
Charney
> to think Pythonically , instead of dealing with the frustration of
expecting
> Python to follow C++'s rules. Down that path lies madness.
>
>
> --
> // Brett g Porter * Lead Engineer, Development Practices
> // BgPorter at artlogic.com * www.artlogic.com
> // Art & Logic, Inc. * software engineering and design
> // Desktop * Embedded * Web
>
>





More information about the Python-list mailing list