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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:37:38+00:00 2026-06-17T12:37:38+00:00

I recently was surprised to find that this code would run on Python 2.7

  • 0

I recently was surprised to find that this code would run on Python 2.7 just fine but would fail on Python 3.

import datetime

class MyTime(datetime.datetime):
    def __new__(cls, year):
        ob = datetime.datetime.__new__(cls, year, 1, 1)
        return ob

class MySpecialTime(MyTime):
    def __init__(self, *args, **kwargs):
        super(MySpecialTime, self).__init__(*args, **kwargs)

MyTime(2013)
MySpecialTime(2013)

On Python 3.3, the final line crashes with this error:

Traceback (most recent call last):
  File "file.py", line 13, in <module>
    MySpecialTime(2013)
  File "file.py", line 10, in __init__
    super(MySpecialTime, self).__init__(*args, **kwargs)
TypeError: object.__init__() takes no parameters

What is different between Python 2 and 3 that causes this code to fail on 3 only? Hint – adding and __init__ method to MyTime fixes the issue. I’m not interested in correcting the error nor writing better code (I’ve done both of those already). Instead, I want to understand why this happened, and specifically why Python 3.3 behaves differently.

  • 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-06-17T12:37:38+00:00Added an answer on June 17, 2026 at 12:37 pm

    This is the fallout of a decision taken five years ago and enforced now, with Python 3.3, namely:
    http://bugs.python.org/issue1683368

    The __init__ that ends up being called is the one from object, and that one will not accept parameters – it’s a design decision and its reasoning is outlined in the bugreport.

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

Sidebar

Related Questions

I was recently surprised to know that this code compiles (at least on gcc
I was surprised recently to find that it's possible to have a return statement
I recently wrote this and was surprised that it compiles: public class MyGeneric<U, V>
I've recently started learning Scala and was disappointed (but not surprised) that their generics
I recently started learning Python and I was rather surprised to find a 1000
Recently I have started learning rails and was a little surprised that the default
I recently installed AnkhSvn for VisualStudio in my laptop. It was fine initially, but
I was recently surprised to note that compiling with /GS (Enable buffer security check)
I recently came across this blog post which basically says that we should not
I saw a tweet recently that confused me (this was posted by an XNA

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.