Forbid old-styled classes
See original GitHub issueIn python2
we had different classes: class Some:
and class Some(object):
were totally different things.
Currently, we don’t have this thing in python3
, but since these times I believe that new-styled classes are still better.
- It has more semantics: this class is related to
object
- It has unified interface:
class Base(object)
andclass Child(Base)
vsclass Base
andclass Child(Base)
- Explicit is better than implicit
So, I believe we should ban classes with old-styled base class. General rule is: always write super-classes’ names
Correct
class Philosopher(object):
def __init_subclass__(cls, default_name, **kwargs):
...
class AustralianPhilosopher(Philosopher, default_name="Bruce"):
...
class WithMetaClass(object, metaclass=MyMeta):
...
Wrong
class Philosopher: ...
class AustralianPhilosopher(default_name="Bruce"): ...
class WithMetaClass(metaclass=MyMeta): ...
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (8 by maintainers)
Top Results From Across the Web
How can I prevent automatic body subscripting when using ...
I'm using Overleaf with the tufte-book class to create lecture notes for an aviation course. When departing from Dallas-Fort Worth International ...
Read more >Embind — Emscripten 3.1.26-git (dev) documentation
Embind is used to bind C++ functions and classes to JavaScript, so that the compiled code can be used in a natural way...
Read more >Python's Super Considered Harmful - James Y. Knight
This turns out to work fine, as long as the oldstyle classes (that do not use ... If you don't do this, forbid...
Read more >Oldstyle / Fabian Iwand - Observable
Oldstyle. Allows toggling between the current default CSS and a CSS ... keyword,a[href]{color:#3182bd}.hljs-deletion,.hljs-variable,.observablehq--forbidden ...
Read more >Prevent EntityManager persisting| JBoss.org Content Archive (Read ...
@Stateless public class MyClassBean implements MyClass ... The idea that session beans are never used in the presentation tier is oldstyle EJB2 thinking....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
And good developer knows that. But you cannot clearly see the difference between these classes though.