destructors order not guaranteed?
Darren New
dnew at san.rr.com
Wed Nov 1 12:53:06 EST 2000
William S. Lear wrote:
> def test():
> a = foo(1)
> if 1:
> b = foo(2)
>
> if __name__ == '__main__':
> test()
> ...
>
> What I dislike is that test() builds a, then b, but a is then
> destroyed before b. I prefer the C++ behavior in this case:
>
> void test() {
> foo a(1);
> if (true) {
> foo b(2);
> }
> }
I'm a python newbie, but I know enough to know that in your first example,
test() has only one scope, while the C++ code has two. What happens if you
do
void test() {
foo a(1);
foo b(2);
}
?
--
Darren New / Senior MTS & Free Radical / Invisible Worlds Inc.
San Diego, CA, USA (PST). Cryptokeys on demand.
The tragedy of the commons applies to monitizing eyeballs, too.
More information about the Python-list
mailing list