is super() safe to use with Phoenix?

Hi,

On this page:
http://wxpython.org/Phoenix/docs/html/MigrationGuide.html

It shows this example of Phoenix code:

class MyDialog(wx.Dialog):
    def __init__(self, parent, ID, title):
        wx.Dialog.__init__(self)
        self.SetExtraStyle(wx.FRAME_EX_CONTEXTHELP)
        self.Create(parent, ID, title)

Is there any reason it can’t be written in “purer” Python 3 style?

class MyDialog(wx.Dialog):
    def __init__(self, parent, ID, title):
        super().__init__()
        self.SetExtraStyle(wx.FRAME_EX_CONTEXTHELP)
        self.Create(parent, ID, title)

Thanks.

Hi Mark,

···

Hi,

On this page:
http://wxpython.org/Phoenix/docs/html/MigrationGuide.html

It shows this example of Phoenix code:

class MyDialog(wx.Dialog):
    def __init__(self, parent, ID, title):
        wx.Dialog.__init__(self)
        self.SetExtraStyle(wx.FRAME_EX_CONTEXTHELP)
        self.Create(parent, ID, title)

Is there any reason it can’t be written in “purer” Python 3 style?

class MyDialog(wx.Dialog):
    def __init__(self, parent, ID, title):
        super().__init__()
        self.SetExtraStyle(wx.FRAME_EX_CONTEXTHELP)
        self.Create(parent, ID, title)

Thanks.

No, there is no reason not to use the Python 3 style. In fact, the wxPython Cookbook by Cody Precord uses that style throughout most of the book. The examples on the website are a bit old.

On Mon, Nov 24, 2014 at 6:02 AM, Mark Summerfield list@qtrac.plus.com wrote:


Mike Driscoll

Blog: http://blog.pythonlibrary.org

Book: https://gumroad.com/l/bppWr

Hi Mark,

Hi,

On this page:
wxPython Project Phoenix Migration Guide — wxPython Phoenix 4.2.3a1 documentation

It shows this example of Phoenix code:

class MyDialog(wx.Dialog):
     def __init__(self, parent, ID, title):
         wx.Dialog.__init__(self)
         self.SetExtraStyle(wx.FRAME_EX_CONTEXTHELP)
         self.Create(parent, ID, title)

Is there any reason it can't be written in "purer" Python 3 style?

I use it quit a bit already with Classic.

class MyDialog(wx.Dialog):
     def __init__(self, parent, ID, title):
         super().__init__()
         self.SetExtraStyle(wx.FRAME_EX_CONTEXTHELP)
         self.Create(parent, ID, title)

I think the super line should be:

super(MyDialog, self).__init__()

Werner

···

On 11/24/2014 13:02, Mark Summerfield wrote:

The resource I always refer to when super() gets mentioned Python’s super() considered super! | Deep Thoughts by Raymond Hettinger

···

On 24/11/2014 17:12, Werner wrote:

Hi Mark,

On 11/24/2014 13:02, Mark Summerfield wrote:

Hi,

On this page:
wxPython Project Phoenix Migration Guide — wxPython Phoenix 4.2.3a1 documentation

It shows this example of Phoenix code:

class MyDialog(wx.Dialog):
     def __init__(self, parent, ID, title):
         wx.Dialog.__init__(self)
         self.SetExtraStyle(wx.FRAME_EX_CONTEXTHELP)
         self.Create(parent, ID, title)
Is there any reason it can't be written in "purer" Python 3 style?

I use it quit a bit already with Classic.

class MyDialog(wx.Dialog):
     def __init__(self, parent, ID, title):
         super().__init__()
         self.SetExtraStyle(wx.FRAME_EX_CONTEXTHELP)
         self.Create(parent, ID, title)

I think the super line should be:

super(MyDialog, self).__init__()

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

Mark Summerfield wrote:

Hi,

On this page:
wxPython Project Phoenix Migration Guide — wxPython Phoenix 4.2.3a1 documentation

It shows this example of Phoenix code:

class MyDialog(wx.Dialog):
    def __init__(self, parent, ID, title):
        wx.Dialog.__init__(self)
        self.SetExtraStyle(wx.FRAME_EX_CONTEXTHELP)
        self.Create(parent, ID, title)

Is there any reason it can't be written in "purer" Python 3 style?

Of course it can. Does it matter? No. Is it important? No. This is
a style issue. When Phoenix issues are ranked in order of importance,
this is #22,139. Please continue to hold. Your call is very important
to us. :wink:

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Hi Werner,

The call you show - super(Class, self).method() is necessary in Python 2; but in Python 3, super().method() is sufficient.

···

On Monday, November 24, 2014 5:12:00 PM UTC, werner wrote:

Hi Mark,

On 11/24/2014 13:02, Mark Summerfield wrote:

Hi,

On this page:

http://wxpython.org/Phoenix/docs/html/MigrationGuide.html

It shows this example of Phoenix code:

class MyDialog(wx.Dialog):

 def  __init__(self,  parent,  ID,  title):
     wx.Dialog.__init__(self)
     self.SetExtraStyle(wx.FRAME_EX_CONTEXTHELP)
     self.Create(parent,  ID,  title)    

Is there any reason it can’t be written in “purer” Python 3 style?

I use it quit a bit already with Classic.

class MyDialog(wx.Dialog):

 def  __init__(self,  parent,  ID,  title):
     super().__init__()
     self.SetExtraStyle(wx.FRAME_EX_CONTEXTHELP)
     self.Create(parent,  ID,  title)    

I think the super line should be:

super(MyDialog, self).init()

Werner

But is the former (super(Class, self)) erroneous in Python 3, or just verbose?

···

On Monday, November 24, 2014 12:20:07 PM UTC-8, Mark Summerfield wrote:

Hi Werner,

The call you show - super(Class, self).method() is necessary in Python 2; but in Python 3, super().method() is sufficient.

It is valid but I personally would consider it poor style.

The other problem with both Class.method(self) and super(Class, self).method() is that you must be explicit about the class, whereas with super().method(), Python figures out the class for you.

Why does this matter? Well, probably it doesn’t in most cases. But if you decide to change your class hierarchy and put a class in between this subclass and the original parent class, you’d have to change all Class references to the new class – super(DerivedClass, self).method(); but any super().method() calls will just do the right thing.

···

On Monday, November 24, 2014 8:26:33 PM UTC, Nathan McCorkle wrote:

On Monday, November 24, 2014 12:20:07 PM UTC-8, Mark Summerfield wrote:

Hi Werner,

The call you show - super(Class, self).method() is necessary in Python 2; but in Python 3, super().method() is sufficient.

But is the former (super(Class, self)) erroneous in Python 3, or just verbose?