Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
38 views

I have a setup like the following from typing import Generic, TypeVar T = TypeVar("T") class ThirdParty: def __init_subclass__(cls): ... # does not call super() class Mine(...
Daraan's user avatar
  • 5,166
0 votes
0 answers
14 views

How can I move then event handling into the subclass of a JComboBox? I can make it work if everything is in TopLevel but, I want to move the event handling (actionPerformed(ActionEvent e)) into a ...
Xorange's user avatar
  • 11
2 votes
1 answer
178 views

One use of __slots__ in Python is to disallow new attributes: class Thing: __slots__ = 'a', 'b' thing = Thing() thing.c = 'hello' # error However, this doesn’t work if a class inherits from ...
Manngo's user avatar
  • 17k
-2 votes
2 answers
93 views

I have five classes. My Main class, a form class, two subclasses that extend the form class and a createForm class I am forced to use to create new instances of the subclass. public class FormenFabrik ...
Wannabree's user avatar
0 votes
0 answers
31 views

I'm relatively new to Java and object oriented programming, and I don't understand why sometimes the constructor used in declaring and object will be a subclass of the objects type instead of the ...
Bluebox's user avatar
  • 13
1 vote
2 answers
101 views

Given this code: class Foo { data = { x: 1 }; } class Bar extends Foo { override data = { ...super.data, y: 1 }; } TypeScript complains on the super.data part: Class field 'data' defined by the ...
user avatar
1 vote
1 answer
63 views

What's the best way in python to create a subclass of an existing class, in such a way that a custom error is raised whenever you attempt to modify the object? The code below shows what I want. class ...
Keplerto's user avatar
  • 121
1 vote
0 answers
72 views

I am in the following situation: I have a type A, two subtypes B and C of A, a function f of type A -> A that is such that for any B object x, f(x) is of type B; for any C object x, f(x) is of ...
Plop's user avatar
  • 161
0 votes
1 answer
28 views

An example of replacing a lambda with a subclass in code is as follows: scale = tf.Variable(1.) scale_layer = tf.keras.layers.Lambda(lambda x: x * scale) Because scale_layer does not directly track ...
joseph king's user avatar
1 vote
1 answer
107 views

I get the following error when creating a custom exception in a C++ module: C:/Sync/Engine/Chorus/Base/win_9x.cpp:600:59: error: conflicting declaration of C function 'void __cxa_throw(void*, void*, ...
Warpspace's user avatar
  • 3,519
0 votes
1 answer
130 views

I'm writing a battleships game for my college project and I want to randomize the positions of the ships in the beginning of the game. My program has an abstract superclass of Ship which branches out ...
okaycomputer's user avatar
1 vote
2 answers
74 views

I want to extend the functionality of a standard list, subclassing seems like the obvious way. Actually, I'm using this to store a mathematical expression in Reverse Polish Notation (RPN) for a ...
Steven Dickinson's user avatar
2 votes
2 answers
243 views

I am using Java 21. I have two classes: abstract class MySuperClass { private final Object mySuperField; MySuperClass(Object myField) { this.mySuperField = myField; } public ...
Amateur Linguist's user avatar
-1 votes
2 answers
55 views

So, I am a total beginner in Java. I need a program that takes a number of players as an input. Then assuming there are 91 domino tiles each with two squares with dots ranging from 0 to 12 in each ...
PabloSaint's user avatar
1 vote
0 answers
114 views

I am trying to understand the difference between SPARQL Query and Snap SPARQL Query tabs on Protege Desktop version. I want retrieve all the direct subclasses of a certain class, say class A, and not ...
User's user avatar
  • 398
0 votes
0 answers
35 views

I want a group of classes that are enum-like; we can't subclass enum, so a small class with one final int will do (const even better). I want the superclass to define some default behaviors, and let ...
Lee Daniel Crocker's user avatar
1 vote
0 answers
137 views

I'm trying to use pydantic together with ABC. I created a base class Datasource and four subclasses: from pydantic import BaseModel from typing import Literal, Union, TypeVar from devtools import ...
MaPo's user avatar
  • 887
0 votes
4 answers
209 views

The following class Point contains a class instance variable @count that counts the number of instances created. It seems to work fine: class Point @count = 0 class << self ...
user200783's user avatar
  • 14.5k
1 vote
1 answer
39 views

OptionsAndAnswer is the base class. abstract class OptionsAndAnswer( ..., open val options: List<Option> ){ fun validate() { require(options.map { it.id }.distinct().size == ...
Kun.tito's user avatar
  • 485
0 votes
0 answers
413 views

I'm using the subclassing API in Tensorflow to build a simple MLP model. from tensorflow.keras import Model from tensorflow.keras.optimizers import AdamW from tensorflow.keras.layers import Dense ...
Bawb's user avatar
  • 33
2 votes
2 answers
101 views

I'm subclassing pandas DataFrame in a project of mine. Most pandas operations preserve the subclass type, but df.groupby().agg() does not. Is this a bug? Is there a known workaround? import pandas as ...
rasputin's user avatar
  • 395
1 vote
1 answer
41 views

Here I have created a Car Class. I have also created another class called Battery and then a sub class ElectricCar that takes from the Car class. I then begin to create an Instance Tesla then I ...
The Code 's user avatar
0 votes
1 answer
88 views

I have a Game that references classes HouseRules, Card, and Player. I'd like to add functionality to each class. I've made a subclass called Game and subclasses called HouseRules, Card, and Player ...
WeCanDoItGuys's user avatar
1 vote
2 answers
80 views

Given a base class named ParentClass, how can I find all leaf subclasses of it? For example, if I have: class ParentClass: pass class SubClass1(ParentClass): pass class SubClass2(ParentClass)...
Logitude's user avatar
0 votes
1 answer
72 views

From what I recall, PyPy has special optimizations on built-in types like ints and lists, which is great because they are very common, and it would be wasteful to treat an int like any other object. ...
qwr's user avatar
  • 11.6k
1 vote
1 answer
41 views

Pickling a subclass that adds a new attribute doesn't seem to include the new attribute. For example: import requests import pickle class MySession(requests.Session): def __init__(self, *args, **...
Brian's user avatar
  • 150
1 vote
1 answer
440 views

Using mapstruct v. 1.5.5, java v. 22. Let's say I have some entities that I am wanting to map to DTOs. The DTOs are java records. My base entity looks like this (simplified): public abstract class ...
Jermeel's user avatar
  • 11
0 votes
1 answer
100 views

I hope someone can help me since can't quite understand how it is possible that the following code can work. I have a base class with some classes that derive from it. Each derived class has its own ...
lightimpact90's user avatar
0 votes
1 answer
144 views

I am working on making a subclass of the rustworkx.PyGraph class, and I am getting some strange behavior. Namely, it does not allow me to pass keyword arguments to my class. Here is a minimal example: ...
Squircle's user avatar
-1 votes
1 answer
77 views

I have a question regarding the init method for subclasses in Python. In the image above, a child class Developer is being defined from a parent class Employee. In Developer, the __init__ method is ...
Agustin G.'s user avatar
1 vote
3 answers
100 views

I am trying to simulate a LFU cache. The task is simple; with any new request I want the cache to print out the key of the request and whether it was a HIT or a MISS. E.g.10 MISS 10 HIT 20 MISS 10 HIT ...
user1752873's user avatar
-1 votes
1 answer
90 views

If I have a class B that inherits from class A and overrides one of its methods, and I have, in TypeScript: const a: A = new A(); (a as B).toto(); Why is the toto() method that will be called the one ...
coilvoltic's user avatar
0 votes
1 answer
50 views

I have the superclass A, and its subclass B and C. I have the class D, and its member: A* aArray[20] but in aArray, there will be just B and C objects. I want to implement a function that will count ...
serkan ertas's user avatar
-3 votes
3 answers
109 views

I’m a computer science teacher at a high school, and I’m teaching polymorphism in Java. My students asked me this question, and I didn’t have a good answer. Let’s say I have an Employee class. Also, I ...
Navarun Jagatpal's user avatar
0 votes
1 answer
35 views

I write a query to solve this problem, Print Organization name that have at least three organization subset. SELECT DISTINCT ?Name WHERE { ?organization a foaf:Organization . ?organization ...
Caty2014's user avatar
0 votes
2 answers
214 views

Inspired by an answer about a plugin architecture, I was playing around with PEP-487's subclass registration and found that it led to surprising results when changing the code slightly. The first step ...
FriendFX's user avatar
  • 3,089
1 vote
1 answer
27 views

I wrote a Threader class using the threading module that creates multiple threads to perform a task (function) on a list of elements. I´m passing slices of said list into a threading.Thread object ...
Altanir Junior's user avatar
0 votes
2 answers
44 views

Currently I have a class-definition that looks something like this: class cls_A: def __init__(self, a1, a2, a3): x = a1 + a2 y = a2 + a3 self.__plot__(self) # some ...
joseph praful's user avatar
1 vote
1 answer
106 views

From https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html: "You don't have to provide any constructors for your class, but you must be careful when doing this. The compiler ...
Derek Dilger's user avatar
0 votes
1 answer
686 views

I want to validate a field in a pydantic model that is a subclass of another model. The class assigned to this field can change, but will always be a subclass of this specific model. I am getting an ...
JJ Fantini's user avatar
0 votes
1 answer
120 views

Let's say I have defined a subclass inherited from Path, and I want to use methods from Path. For example, Path.glob() here: from pathlib import Path class PhotoDir(Path): pass # some custom ...
INT3RFACE's user avatar
0 votes
0 answers
54 views

The string value seems to appear yet I can not add a value to my calculations in the fulltime and part time. This is the Main class for my inheritance import java.util.Scanner; public class ...
玉ねぎ忍者's user avatar
1 vote
1 answer
486 views

When subclassing a lit-element Class to add further typing, should the @property decorator be overridden or just the type and initializer? In otherwords, suppose I have this code: interface AB { a:...
Michael Scott Asato Cuthbert's user avatar
2 votes
3 answers
510 views

I have a class Item, and there are two classes derived from it Sword and Shield. I want my player to have an array of items: class Item { int x; }; class Sword : public Item { int sharpness =...
whatupo9's user avatar
  • 165
1 vote
1 answer
54 views

I want to create a numpy subclass specialized for symmetric matrices. I want it to be just like any numpy array with only 2 differences: It will have 2 fields for its eigendecomposition: U, D. On ...
David's user avatar
  • 165
-2 votes
1 answer
121 views

I have a class that extends another class. Depending on a user's input, if the input "A" then the class needs to be a subclassA, but if they input "B" it will be a subclassB. I ...
J C's user avatar
  • 1
0 votes
1 answer
78 views

Imagine a ontology with several classes and subclasses. Now i use another namespace to instantiate for example a MathTeacher. MathTheacher is a subclass of Teacher and Teacher a subclass of Job. Now i ...
Max Berktold's user avatar
0 votes
0 answers
34 views

ABOUT ME: I am learning Java because I want to become a software developer someday and I came across the topic of subclasses and their ability to inherit from superclasses on tutorialspoint.com. where ...
Nahum Auguste's user avatar
0 votes
1 answer
255 views

Question What is the current (~2024) solution to extend/wrap/intercept/decorate a typescript class with additional behaviour to separate concerns? There are various questions regarding wrapper classes,...
Samuel's user avatar
  • 6,520
1 vote
1 answer
700 views

I'm now to angular and have just completed my first implementation of angular inheritance. I need to write a test case for the subclass where I cam assign value to protected variable (coming from base ...
Shweta Shetty 's user avatar

1
2 3 4 5
84