Does Python cache the startup module?

Fredrik Lundh fredrik at pythonware.com
Mon Jan 7 14:30:23 EST 2008


Baz Walter wrote:

> It's hard to supply an example for this, since it is local to the machine I am 
> using. The startup module would look something like this:

would look, or does look?  if it doesn't look like this, what else does 
it contain?

> #!/usr/local/bin/python
> 
> if __name__ == '__main__':
>     
>     import sys
>     from qt import QApplication, QWidget
> 
>     application = QApplication(sys.argv)
>     mainwindow = QWidget()
>     application.setMainWidget(mainwindow)
>     mainwindow.show()
>     sys.exit(application.exec_loop())
> 
> If I change the name 'mainwindow' to 'mainwidget', the widget it refers to does 
> not get destroyed; when I change it back again, it does get destroyed. 
> Otherwise, the program runs completely normally.

I don't see any code in there that destroys the widget, and I also don't 
see any code in there that creates more than one instance of the main 
widget.

what do you do to run the code, and how to you measure leakage?

is the name "mainwidget" used for some other purpose in your application?

</F>




More information about the Python-list mailing list