Skip to main content
243 votes
18 answers
182k views

How does one go about and try to find all subclasses of a given class (or all implementors of a given interface) in Java? As of now, I have a method to do this, but I find it quite inefficient (to say ...
Avrom's user avatar
  • 5,057
341 votes
13 answers
206k views

I need a working approach of getting all classes that are inherited from a base class in Python.
Roman Prykhodchenko's user avatar
5 votes
3 answers
6k views

So, i'm trying to learn python and every time i post a question here it feels like giving in... I'm trying to make my own class of turtle.Turtle. import turtle class TurtleGTX(turtle.Turtle): ...
Drew Verlee's user avatar
  • 1,900
109 votes
6 answers
136k views

I am debugging some code and I want to find out when a particular dictionary is accessed. Well, it's actually a class that subclasses dict and implements a couple extra features. Anyway, what I would ...
Michael Mior's user avatar
423 votes
5 answers
272k views

To check if a type is a subclass of another type in C#, it's easy: typeof (SubClass).IsSubclassOf(typeof (BaseClass)); // returns true However, this will fail: typeof (BaseClass).IsSubclassOf(typeof ...
Daniel T.'s user avatar
  • 38.6k
64 votes
2 answers
31k views

The following code works: class Foo(tuple): def __init__(self, b): super(Foo, self).__init__(tuple(b)) if __name__ == '__main__': print Foo([3, 4]) $ python play.py Result: play....
Sridhar Ratnakumar's user avatar
215 votes
5 answers
72k views

This came up in Hidden features of Python, but I can't see good documentation or examples that explain how the feature works.
miracle2k's user avatar
  • 32.7k
68 votes
2 answers
34k views

I'm interested in subclassing the built-in int type in Python (I'm using v. 2.5), but having some trouble getting the initialization working. Here's some example code, which should be fairly obvious. ...
me_and's user avatar
  • 15.8k
5 votes
3 answers
3k views

I have these 4 java clases: 1 public class Rect { double width; double height; String color; public Rect( ) { width=0; height=0; color="transparent"; ...
engy's user avatar
  • 139
258 votes
5 answers
168k views

I want to allow type hinting using Python 3 to accept sub classes of a certain class. E.g.: class A: pass class B(A): pass class C(A): pass def process_any_subclass_type_of_A(cls: A): ...
user1211030's user avatar
  • 3,150
37 votes
3 answers
28k views

I've asked a few questions on stack overflow about subclassing a UIButton, and a couple of people have informed me that I shouldn't subclass a UIButton. What are the negatives of subclassing a ...
SirRupertIII's user avatar
  • 12.7k
18 votes
9 answers
52k views

Animal is a superclass of Dog and Dog has a method called bark public void bark() { System.out.println("woof"); } Consider the following: Animal a = new Dog(); if (a instanceof Dog){ a.bark(...
user avatar
26 votes
15 answers
40k views

I have a question about inheritance in Java. I have two classes A and B , and class B, inherits from A: public class A { public A() { System.out.println("Hi!"); } } public class B ...
user42155's user avatar
  • 49.7k
195 votes
11 answers
101k views

Why did the Python designers decide that subclasses' __init__() methods don't automatically call the __init__() methods of their superclasses, as in some other languages? Is the Pythonic and ...
jrdioko's user avatar
  • 33.9k
17 votes
8 answers
10k views

I have a very simple class which I want to use as a subclass of another one. But when I put its code in the parent's class I get : non-static variable this cannot be referenced from a static ...
Patryk's user avatar
  • 24.5k

15 30 50 per page
1
2 3 4 5
32