How to call a class objects's method if it is not assigned to a variable in python?
Question: Please see the code below, how do I call the `GetCurrentSelection()` method of
`Choice()` object below? `Choice()` object is not assigned to a variable.

    
    
    import wx
    
    class ChoiceFrame(wx.Frame):
        def __init__(self):
            wx.Frame.__init__(self, None, -1, 'Choice Example', 
                    size=(250, 200))
            panel = wx.Panel(self, -1)
            sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
                          'six', 'seven', 'eight']
            wx.StaticText(panel, -1, "Select one:", (15, 20))
            wx.Choice(panel, -1, (85, 18), choices=sampleList)
    
    
    if __name__ == '__main__':
        app = wx.PySimpleApp()
        ChoiceFrame().Show()
        app.MainLoop() 
    

If it was written this way:

    
    
    choice_object = wx.Choice(panel, -1, (85, 18), choices=sampleList)
    

Then I would do:

    
    
    choice_object.GetCurrentSelection()
    

But it has no variable names, so how will I call `GetCurrentSelection()`
method in original code above?


Answer: Depending on your needs, you could call the `GetCurrentSelection` method when
you create the `Choice`:

    
    
    wx.Choice(panel, -1, (85, 18), choices=sampleList).GetCurrentSelection()
    

I don't know why you're not just storing the choice, though. Variables exist
for a reason.

