Skip to main content
Filter by
Sorted by
Tagged with
0 votes
3 answers
96 views

I want to construct objects which support arithmetic operations and have extra methods, e.g: class Timestamp(int): def as_seconds(self): return self / 90000 The extra method works: >&...
tuserun's user avatar
  • 11
0 votes
1 answer
66 views

I'm trying to subclass an edit box in a dialog in VS C++ 2022. I want to intercept any key presses in a particular edit box to do further processing. Here's my code. The 4th line confuses me because I ...
WillDotson's user avatar
1 vote
2 answers
118 views

I'm new to JS and implementing a polymorphic class hierachy. It appears that within the super constructor (when called from a derived constructor), 'this' refers to the derived class, not the super ...
TreeTownGreen's user avatar
0 votes
1 answer
106 views

I want to color a TButton control in C++Builder. I am trying to follow the information I found that suggests using SetWindowLong() to enable the BS_OWNERDRAW style for my TButton control, then catch ...
Kevin's user avatar
  • 52
0 votes
0 answers
107 views

I've been trying to solve this little problem the whole day, and I can't figure out what's wrong. I suppose this is a simple problem for some. So I'm trying to Subclass Notepad with a procedure that ...
Whicked Hayo's user avatar
1 vote
1 answer
73 views

I have a sequence of 16 elements (dealer and vulnerability of bridge boards, to be specific) that repeat endlessly in theory (in practice it almost never gets past 128, and rarely past 36). That is, ...
Mycroft's user avatar
  • 113
0 votes
0 answers
64 views

Suppose that you want to create a new subclass for float, using the following code: class MyFloat(float): def __new__(cls,number,extra): return super().__new__(cls,number) def ...
Glen O's user avatar
  • 733
1 vote
1 answer
209 views

I'm attempting to create a subclass of pathlib.Path that will do some manipulation to the passed string path value before passing it along to the base class. class MyPath(Path): def __init__(self, ...
Kyle's user avatar
  • 4,406
1 vote
1 answer
279 views

(tensorflow 2.17, Windows 10) I can't save and restore a custom model using subclassing method. Please find below the code to reproduce the problem : import numpy as np import tensorflow as tf x = np....
u2gilles's user avatar
  • 7,425
1 vote
1 answer
116 views

I'm trying to write an inheritence logic where I clone an input class and inherit from remaining parent classes. In order to do that, I need to create a new class, deep copying one of the classes ...
ozgeneral's user avatar
  • 6,899
0 votes
0 answers
53 views

I'll call an "atomic" attribute of a python class to be one from which all other user defined attributes derive. For example, the attribute a in the class below is atomic to A because all ...
gdavtor's user avatar
  • 570
1 vote
0 answers
175 views

I have an existing enumeration with a number of values defined in package b, and I want to add behavior in the current package a. I understand that you can't directly subclass an enum with existing ...
Paul's user avatar
  • 311
1 vote
0 answers
89 views

I have developed a class that subclasses from CMFCButton. I load three PNG images (with transparent zones) to the button foreground in the DrawButton function for three states: Normal Hovered Pushed ...
al072's user avatar
  • 99
1 vote
0 answers
39 views

I'm trying to implement my subclass of pd.Series, but original pd.Series methods don't work as expected and return Nan class Subclass(pd.Series): # see https://pandas.pydata.org/pandas-docs/stable/...
Mary.A's user avatar
  • 23
1 vote
2 answers
88 views

Is there a way to subclass set, with the binary operator returning the subclassed type, without redefining them ? example : class A(set): pass a = A([1,2,3]) & A([1,2,4]) a.__class__ == A # ...
hl037_'s user avatar
  • 3,947
0 votes
0 answers
22 views

I have a working application in Pyside2 that displays a QSqlTableModel in a QSqlTableView. Three of the fields display raw seconds, like "6282" meaning six thousand and some seconds into a ...
Persistent at Python's user avatar
0 votes
0 answers
70 views

EPOCHS = 10 LR = 0.001 loss_object = MeanSquaredError() optimizer = Adam(learning_rate = LR) load_metrics() @tf.function def trainer(): global train_ds, train_loss, model global optimizer, ...
LHB's user avatar
  • 11
0 votes
1 answer
81 views

I come from a C/C++ background I would like to subclass dict to make one that automatically opens a JSON file. Here's the code and problem: class DictFromJSON(dict): def get_from_file(self, ...
Kiwewi's user avatar
  • 1
1 vote
1 answer
168 views

Regarding the following example code, is there any type-safe way of automatically forwarding any of the prototypal method calls, each to its related method of another object? class Foo { greet() { ...
Adam B.'s user avatar
  • 1,190
0 votes
0 answers
52 views

Target I'm dealing with 2D time-series data, and never use negative indexing. So I want to subclass np.ndarray that negative and out-of-bound indexing in axis 0 will return a nan-augmented matrix with ...
LeonM's user avatar
  • 45
3 votes
1 answer
66 views

Somebody here on SO wanted to alter the behavior of UIAlertAction buttons in a specific UIAlertController, but not others. (They wanted multi-line button labels for one alert but normal behavior for ...
Duncan C's user avatar
  • 132k
0 votes
3 answers
872 views

I have an unusual situation where I need to dynamically generate a class prototype then have a reflection tool (which can't be changed) walk the prototype and find all the methods. If I could hard ...
DoomGoober's user avatar
  • 1,753
1 vote
1 answer
190 views

I have a base Message class and an subclass SpecializedMessaged for extra features class Message { constructor( readonly content: string ) { } edit(replacement: string) { ...
pinkboid's user avatar
  • 383
1 vote
1 answer
146 views

In the numpy documentation of subclassing ndarray here. It is said that ndarray.__new__, passes __array_finalize__ the new object, of our own class (self) as well as the object from which the view ...
Zhang Daniel's user avatar
0 votes
0 answers
30 views

I have multiple Models that all need some shared functionality. My existing code uses a Mixin class: class MyMixing: some_class_variable = None @classmethod def get_headers(cls): ...
Granny Aching's user avatar
1 vote
1 answer
122 views

The following code: class Foo(int): def __new__(cls, x, *args, **kwargs): x = x if isinstance(x, int) else 42 return super(Foo, cls).__new__(cls, x, *args, **kwargs) ...
Grismar's user avatar
  • 32.4k
1 vote
1 answer
149 views

I read the Design Patterns book (written by the Gang of Four) and I'm now recapping on the Prototype Design pattern. In the consequence section, of the Prototype design pattern, (explained on page 119 ...
Niek Beijloos's user avatar
1 vote
1 answer
64 views

I'm trying to catch a message in a subclassed form and make a new event from it so I can check things before it happens and then cancel the message if needed. I want to know if the user is trying to ...
Arvo Bowen's user avatar
  • 4,968
1 vote
1 answer
866 views

I am currently trying to implement a subclass (called 'Pointer_dict') for the python dictionary class dict. The purpose of this class is to save memory when creating copies of dictionaries and ...
Xian's user avatar
  • 11
1 vote
2 answers
520 views

I'm creating a subclass of the NodeJS http.Agent to get rid of the queuing behavior when it has reached the socket limit. I've overridden addRequest to track the number of concurrent requests per ...
spurrkins's user avatar
  • 126
0 votes
2 answers
254 views

Given a simple class: class MyClassA(): def __init__(self, param_a, param_b): self.param_a = param_a self.param_b = param_b def my_method(self, param_c): ...
Eric Johnson's user avatar
1 vote
2 answers
455 views

I am running this test with Python 3.10.9 and PyCharm 2022.2.1 (Community Edition). This is an issue with PyCharm, not Python itself. In my example code, I use a generator method that takes in a class ...
reid-sutherland's user avatar
0 votes
1 answer
355 views

I want to cythonize code that uses a subclass of "int", which behaves actually like a set (similar to C++ bitset). The pure python object is instantiated with __new__: class BitSet(int): ...
PlasmaBinturong's user avatar
0 votes
1 answer
158 views

I am trying to define a class that is supposed to simultaneously do two things: serve as the metaclass for a dataclass act like a mapping i.e., it will need to be derived from both type and typing....
joxirerehufe's user avatar
1 vote
1 answer
469 views

Currently I am learning subclassing with Keras. Thus far I have built my models using the functional API. For the paper I try to recreate at the moment subclassing would be really helpful though. My ...
lenna's user avatar
  • 11
1 vote
1 answer
269 views

I have a custom Sympy cSymbol class for the purpose of adding properties to declared symbols. This is done as follows: class cSymbol(sy.Symbol): def __init__(self,name,x,**assumptions): ...
pfloutch's user avatar
1 vote
3 answers
572 views

I would like to subclass torch.Tensor to make tensors that will always satisfy some user-defined property. For example, I might want my subclassed tensor to represent a categorical probability ...
Doug Tischer's user avatar
0 votes
0 answers
20 views

I have this code: from abc import ABC class ConfigProto(ABC): def __init__(self, config_dict): self._config_dict = config_dict def parse(self, cfg_store: dict) -> None: # ...
Adam Bajger's user avatar
1 vote
1 answer
194 views

I currently have the following setup: enum EnumA { A, AYE } enum EnumB { B, BEE } type A = keyof typeof EnumA type B = keyof typeof EnumB type AB = A | B interface IBase { foo:...
JasonBourne's user avatar
0 votes
1 answer
25 views

My base class and internal subclass in c2base.py class C2Methods(object): _instruction = {} _request = {} _paramter = {} _data = {} _responsedata = {} def init(self, instruction, ...
Mike Oliver's user avatar
0 votes
1 answer
38 views

For subclassing to create a Tensorflow model with the following code: class MyClass(keras.Model): def __int__( self, input_shape: tuple, classes_count: int = 10, ...
mCs's user avatar
  • 2,979
1 vote
1 answer
1k views

Over the years, I've hooked the WndProc in everything from VB3 to C# in WinForms with no issue, but WINUI-3 and C# is giving me problems. My DLL Imports are: /// <summary> /// ...
Jason Coulls's user avatar
1 vote
0 answers
296 views

I can't figure out how to subclass EarlyStopper to use it as callback in scikit-optimize (gp_minimize). Based on the documentation. How should I think when subclassinging? Documentation: https://...
Henri's user avatar
  • 1,255
2 votes
1 answer
160 views

I wrote an array-like class 'Vector' which behaves like an 'np.ndarray' but has a few extra attributes and methods to be used in a geometry engine (which are omitted here). The MVP below overrides '__ ...
CyrielN's user avatar
  • 99
3 votes
0 answers
59 views

I need to detect from within an excel-addin when a userform is loaded into memory without using the Initialize- or Activate-event of the loaded userform. I'm currently trying to extend an Excel app by ...
Bernd's user avatar
  • 106
2 votes
1 answer
232 views

I am currently working on a PyQgis based standalone application and I need to add various QgsRubberBand to my Canvas. I made a subclass of it : LineAnnotation. The problem is that when I use the ...
Eggdrasil's user avatar
4 votes
0 answers
156 views

I am subclassing a window, and I process the WM_TOUCH messages. When I receive a WM_TOUCH message, I call Dim RetVal& RetVal = GetTouchInputInfo(hTouchInput, TouchPoints, tiTouchInput(1&), ...
tmighty's user avatar
  • 11.6k
0 votes
2 answers
85 views

I'm learning Typescript and I'm trying to run method in a class. I have a Class Person, and two classes which extends the Person Class: Man and Woman. I also have an array of persons, and I need ...
dryant's user avatar
  • 15
0 votes
1 answer
676 views

I'm trying to subclass a URLSessionDataTask as shown in this post Initializer does not override a designated initializer while subclassing NSURLSession Swift Except that the sub class init imposes a ...
jmz49's user avatar
  • 43
3 votes
1 answer
2k views

I would like to create a subclass of URLSession, but I get a warning: 'init()' was deprecated in iOS 13.0: Please use +[NSURLSession sessionWithConfiguration:] or other class methods to create ...
jmz49's user avatar
  • 43

1
2 3 4 5
17