Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6578413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:46:05+00:00 2026-05-25T15:46:05+00:00

As what I just learned, I can use super() this way: super(class, obj_of_class-or-_subclass_of_class) Code

  • 0

As what I just learned, I can use super() this way:
super(class, obj_of_class-or-_subclass_of_class)

Code goes below:

#Case 1
class A(object):
    def __init__(self):
        print "A init"

class B(A):
    def __init__(self):
        print "B init"
        super(B, self).__init__()  #ok, I can invoke A's __init__ successfully

#Case 2
class A(object):
    @classmethod
    def foo(cls):
        print "A foo"

class B(object):
    @classmethod
    def foo(cls):
        print "B foo"
        super(B, cls).foo()   #ok, I can invoke A's foo successfully

#Case 3
class A(object):
    def __new__(cls):
      print "A new"
      return super(A, cls).__new__(cls)

class B(A):
    def __new__(cls):
      print "B new"
      return super(B, cls).__new__()  #Oops, error

QUESTION:

In case 1 and 2, I can use super successfully without specifying the obj or cls to operate on.
But why can’t I do the same for __new__?
Because, in case 3, if I use super that way, I got an error.
But if I use it this way:

super(B, cls).__new__(cls)

No error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:46:06+00:00Added an answer on May 25, 2026 at 3:46 pm

    From the Python release notes on overriding the __new__ method:

    __new__ is a static method, not a class method. I initially thought it
    would have to be a class method, and that’s why I added the
    classmethod primitive. Unfortunately, with class methods, upcalls
    don’t work right in this case, so I had to make it a static method
    with an explicit class as its first argument.

    Since __new__ is a static method, super(...).__new__ returns a static method. There is no binding of cls to the first argument in this case. All arguments need to be supplied explicitly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just learned yesterday from this site that I can: class Seq(object): def __init__(self,
I just learned (the hard way) that Java Component s can only have one
As I just learned from this question , .NET regexes can access individual matches
I just learned that an object can have only one ID, so I'm not
I just learned something interesting. The add method for the javascript select object in
as I've just learned in in my other question , I could use a
I have just learned how to use the SQLite database for local storage in
I've just recently learned how jquery can access dynamically generated content, by placing a
I just learned that I could use chmod make myscript.sh executable and the run
I just learned about .delegate today, and I know I can be used for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.