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 7407579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:44:47+00:00 2026-05-29T05:44:47+00:00

The Changelog for Python 2.2 (where new-style classes were introduced) says the following about

  • 0

The Changelog for Python 2.2 (where new-style classes were introduced) says the following about the __new__ function:

__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.

However, I cannot think of why class methods wouldn’t work for this purpose, and it would certainly look better. Why didn’t __new__ end up as a class method in the end? What does Guido refer to when he says that “upcalls don’t work right in this case”?

  • 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-29T05:44:48+00:00Added an answer on May 29, 2026 at 5:44 am

    __new__ being static method allows a use-case when you create an instance of a subclass in it:

    return super(<currentclass>, cls).__new__(subcls, *args, **kwargs)
    

    If new is a class method then the above is written as:

    return super(<currentclass>, cls).new(*args, **kwargs)
    

    and there is no place to put subcls.

    I don’t really see when that would be a proper use of __new__, though. Maybe I’m not seeing it, but that just seems to me to be a completely pathological use of it (and it should be said, that if you still really want it, then you could access it with object.__new__.__func__). At the very least, I find it very hard to imagine that it would have been the reason for Guido to change __new__ from being a class method to a static method.

    A more common case would be to call parent __new__ without using super(). You need a place to pass cls explicitly in this case:

    class Base(object):
        @classmethod
        def new(cls):
            print("Base.new(%r)" % (cls,))
            return cls()
    
    class UseSuper(Base):
        @classmethod
        def new(cls):
            print("UseSuper.new(%r)" % (cls,))
            return super(UseSuper, cls).new() # passes cls as the first arg
    
    class NoSuper(Base):
        @classmethod
        def new(cls):
            print("NoSuper.new(%r)" % (cls,))
            return Base.new()  # passes Base as the first arg
    
    class UseFunc(Base):
        @classmethod
        def new(cls):
            print("UseFunc.new(%r)" % (cls,))
            return Base.new.im_func(cls)  # or `.__func__(cls)`. # passes cls as the first arg
    
    print(UseSuper.new())
    print('-'*60)
    print(NoSuper.new())
    print('-'*60)
    print(UseFunc.new())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to partly automate creation of GNU-style ChangeLog entries when working with source
An old changelog for phpPgAdmin says that there is an interface for creating and
I have the following link in my view that opens a changelog in a
I've read about how you can generate changelog.xml from an existing schema. That's fine,
https://developers.facebook.com/docs/changelog/ Facebook respond with this in their latest changelog: *publish_action permissions will not be
Possible Duplicate: PHP 5.3 changelog? I am new to PHP, and I am confused
The Backbone 0.9.0 changelog says: A view's events hash may now also contain direct
The changelog lists version 0.7.8 as the version that introduces the $arg_X notation to
I need to create a database table to store different changelog/auditing (when something was
Will Subclipse 1.4.4 work safely with Subversion 1.3.2? I am confused because its changelog

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.