cleaner way to write this?

Ben Finney bignose+hates-spam at benfinney.id.au
Thu Oct 26 01:42:39 CEST 2006


John Salerno <johnjsal at NOSPAMgmail.com> writes:

>          if dlg.ShowModal() == wx.ID_OK:
>              db_name = dlg.GetValue()
>              dlg.Destroy()
>              return db_name
>          else:
>              dlg.Destroy()
>              return

It's for reasons like this that I prefer to have only one 'return'
from my functions.

    db_name = None
    if dlg.ShowModal() == wx.ID_OK:
        db_name = dlg.GetValue()
    dlg.Destroy()
    return db_name

-- 
 \         "I was trying to daydream, but my mind kept wandering."  -- |
  `\                                                     Steven Wright |
_o__)                                                                  |
Ben Finney




More information about the Python-list mailing list