gc question
vpalexander at gmail.com
vpalexander at gmail.com
Sun Mar 9 05:42:01 EDT 2008
I keep seeing destructor calls in wx for ad hoc dialogs and wonder if
this is required, and if so, why would normal gc flow not be good?
def GetDir(self,Caption,DefaultDir):
dlg = wx.DirDialog(None,Caption,style = 1,defaultPath =
DefaultDir,pos = (10,10))
res = dlg.ShowModal()
pck = dialog.GetPath()
dlg.Destroy()
if res == wx.ID_OK:
return pck
else:
return ''
I'd like to write it as:
def GetDir(self,Caption,DefaultDir):
dlg = wx.DirDialog(None,Caption,style = 1,defaultPath =
DefaultDir,pos = (10,10))
if dlg.ShowModal() == wx.ID_OK:
return dialog.GetPath()
else:
return '' # probably implied; del 2 more lines?
...and gc takes care of things once scope is exited? Or is wx more
tricksome than that?
More information about the Python-list
mailing list