Hacker News new | past | comments | ask | show | jobs | submit login

EDIT: nope, nope, this is all wrong. My mistake. Ignore everything else here.

> classes don't need (object) anymore

My friend, old-style classes became unnecessary with the release of Python 2.2 — almost 20 years ago now [0]. I'm afraid you've been living in the past. :)

[0] https://wiki.python.org/moin/NewClassVsClassicClass




Extending `object` was necessary until 2.7 when it became the default and old style classes were removed entirely in 3. So I think while the GP comment recently learned they don’t need to extend `object` anymore, they are/were familiar with new style vs old style classes.


New-style classes never became the default in Python 2:

    Python 2.7.15 (default, Jun 27 2018, 13:05:28) 
    [GCC 8.1.1 20180531] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> class Foo:
    ...   pass
    ... 
    >>> Foo
    <class __main__.Foo at 0x6218e384ee88>
    >>> class Bar(object):
    ...   pass
    ... 
    >>> Bar
    <class '__main__.Bar'>
    >>> isinstance(Bar, type)
    True
    >>> isinstance(Foo, type)
    False


Thank you for the correction! I’ve not used Py2 in 6 or so years.


Right! Yes, another commenter pointed that out to me too. I made a goof and misremembered some things haha. Oops.


Nope, she/he has not. (object) were the new style classes!


Oh man, major brain fart there. You're completely right of course. I was thinking of the transition to classes-as-types in general.

Probably would've helped if I actually read the page I linked...




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: