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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:48:52+00:00 2026-05-16T11:48:52+00:00

Possible Duplicate: Python's use of __new__ and __init__ ? The way I understand it,

  • 0

Possible Duplicate:
Python's use of __new__ and __init__ ?

The way I understand it, __init__ is different from a constructor in Java, because __init__ only initializes an object that has already been constructed implicitly (because __init__ is called after __new__). However, everything that I have ever needed to define has used this latter property of a ‘constructor’ in Java. What would be a case in which a programmer would want to override __new__?

EDIT: For the record, I ask partly because I’m wondering what would be the advantage/disadvantage to overriding new vs. using a separate classmethod in the accepted answer to this question:

Moving Beyond Factories in Python

  • 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-16T11:48:52+00:00Added an answer on May 16, 2026 at 11:48 am

    __new__ actually happens before an object exists. It’s a static method of the type. Uses of __new__ are when you want to control the creation of new objects, e.g. a singleton. If your __new__ always returns the same instance of an object, it’s a singleton. You can’t do that with __init__.

    Generally, in “python as Guido intended it to be” you shouldn’t use __new__ more than once a month 🙂

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

Sidebar

Related Questions

Possible Duplicate: How do you send email from a Java app using Gmail? How
Possible Duplicate: Java Python Integration I have a large existing codebase written in 100%
Possible Duplicate: What version of Python should I use if I’m a new to
Possible Duplicate: Choosing Java vs Python on Google App Engine We are going to
Possible Duplicate: Reading/Writing MS Word files in Python I know there are some libraries
Possible Duplicate: Converting XML to JSON using Python? I am importing an XML feed
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should
Possible Duplicate: .NET - What’s the best way to implement a catch all exceptions
Possible Duplicates: Python: defining my own operators? Rules of thumb for when to use
Possible Duplicate: Python float - str - float weirdness In python, 2/5.0 or 2/float(5)

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.