Questions tagged [super]
super is a keyword or function used to access/invoke members and constructors of a superclass. Since different languages have such a feature, please use in combination with a language tag.
1,762
questions
-1
votes
0
answers
46
views
In python, why super raise argument error in multiple inheritance? [duplicate]
I have a question, or something I don't understand about super() function.
Let's consider this classes. The issue comes with the last one which inherits from both FirstSpecial and Second.
class First:
...
1
vote
2
answers
69
views
Super class has attribute "b", still got "AttributeError: 'super' object has no attribute 'b' "
super class has instance attribute b, I am trying to access it using super() method, then why I am getting Attribute Error? It should access instance variable of superclass, but instead it is giving ...
0
votes
1
answer
44
views
no idea where tkinter label is being defined in class
I found this code for a label class for a tkinter popup I was making. I didn't understand how the label appeared, but I just went on with it. However later I found that I needed to refer to the ...
3
votes
1
answer
59
views
Useless parent or super() delegation in method '__init__'
I'm working through the book Python Crash Course 2nd Edition, and I did what they outlined, but they did something that runs a warning in VS code (Useless parent or super() delegation in method '...
0
votes
0
answers
32
views
attribute that is a list behave weirdly with inherited class [duplicate]
If you compile this python code, what output do you think you'll get?
class Parent:
def __init__(o,ls = []):
o.list_truc = ls
class Truc:
def __init__(o):
pass
class Child(...
-1
votes
1
answer
55
views
How to only execute partial codes of a method of super class in python?
I know how to call the method of super class by using super(), like these:
>>> class A:
>>> def func1(self):
>>> print("1")
>>> print(&...
-1
votes
1
answer
92
views
How to use super with arguments
I have linear hierarchy of classes, A, B, C, sharing a method with a different implementation which depends on the result of the father's one. Such methods have same identifier but different signature ...
0
votes
1
answer
72
views
Java - Need to initialize variable before Constructor calls super()
Note: some of the code will be in spanish.
Hi. I made a good Exception model for my Spring Boot app, so that every personalized exception I throw creates a personalized response (int this case it's a ...
0
votes
0
answers
36
views
python's super - how can I choose which implementation to use? [duplicate]
my question is given this dummy code:
class A:
def display(self): print("FOO")
class B(A):
def display(self): print("BAZ")
class C(B):
def display(self): super()....
0
votes
0
answers
29
views
Python: Nested Inheritance, unable to add argument to a "grand-child" class
I can't figure out why I can't add additional arguments to a "grandchild" class "Rival". In order to be able to add an arg group to the grandchild class "Rival". I have ...
0
votes
2
answers
146
views
Can't access private fields from within the same class
I'm trying to enhance the Map class in JavaScript by adding a TypedMap subclass that extends the Map superclass.
TypeMap.js
export default class TypedMap extends Map {
#keyType;
#valueType;
...
0
votes
0
answers
11
views
Can I invite user to login to my Heroku outside of the collaborators on the app?
I am new to Heroku. I need to get a dev in to make some global changes. It does not appear I can do this without an Enterprise package and was interested to confirm?
I can easily invite as ...
0
votes
1
answer
29
views
What is the point of calling super from base(root) class in this multiple inheritance example?
This is the code I am trying to run which is trying to calculate area of the right pyramid using the concept of multiple inheritance in Python
class Rectangle:
def __init__(self, length, width, **...
0
votes
2
answers
100
views
type hinting super().__init__ call with concrete types
Below are two class trees.
Each with a base class eating the base class of its neighbor class.
Once I derivate a concrete class, I also use the neighbor type as a dependency.
The code works as ...
0
votes
2
answers
48
views
How to concatenate two functions (one from the superclass and the other from the subclass)?
Im studying object oriented programming in python, and when I run the code it is printed on the terminal as two different prints, and i would like to "concatenate" it to be printed in one ...
0
votes
2
answers
30
views
Super method for python multi class inheritance
I'm trying to create a daughter class that inherits from two parent classes, each of which has its own required inputs. However, when I try to initialize the daughter class I am getting an error that ...
0
votes
0
answers
50
views
install module jupyter notebook
I have completed
from ultralytics import NAS
model = NAS('yolo_nas_s.pt')
returns an error:No module named 'super_gradients'
How to install super_gradients in jupyter notebook for YOLO-NAS
what you ...
0
votes
0
answers
23
views
Can I add (or overwrite) the colon operator to __getitem__ of custom subclass? [duplicate]
I'm working out a class to allow nested dictionaries to be indexed like ND arrays, so I want to be able to put a colon in one of the key "slots" so I can get all of the matching entries from ...
0
votes
0
answers
50
views
How to call a superclass method recursivly
In Scala, recursively calling a method of a super class doesn't seem to go through the whole class hierarchy.
Assuming the following simple class tree:
class A {
def f: Int = 1
def g: Int = 0
}
class ...
0
votes
0
answers
39
views
simulating a 'Super exception' in Python
for the past days I have been struggling to find a method to remotely break a function by raising an Exception. I have tried many methods, but the functions never initiate from on_guild_channel_create....
1
vote
1
answer
40
views
How can I get a class using multiple inheritance to call all parents' init methods with arguments?
In my program, I am using abstract base classes to force subclasses to have certain attributes and/or behavior. I am aware this is not particularly pythonic, but the complexity of my code doesn't lend ...
0
votes
0
answers
8
views
Override dialog method from mother class
:
I have a super class and a child class.
The super class have a dialog method.
When I run superclass it runs well showing his dialog method
Depending on combobox opion, I call construct methods
for ...
0
votes
0
answers
24
views
Super function and MRO [duplicate]
So I need some clarification on super() and how it searches MRO. I hear so many people say first it searches in the child class for the method and if not found moves to the next one in the MRO. ...
0
votes
1
answer
60
views
How can I set values from the constructor of the parent class?
I need to create a generic class that is able to dynamically set values based on the properties of the child class. Here are examples:
export class EnderecoMobile extends ModelCore{
id: string = ''
...
0
votes
3
answers
178
views
how to access grandparent attribute in the child class with same name as some attribute in child class
I was tinkering with classes and objects, then I had a doubt, since all the non-private
methods and variables/attributes are available to the child class, and if there is any attribute in the parent ...
0
votes
1
answer
43
views
Invocation of Python's descriptor protocol from super
In the Python Descriptor HowTo guide, it is written that:
A dotted lookup such as super(A, obj).m searches obj.__class__.__mro__
for the base class B immediately following A and then returns
B....
2
votes
3
answers
103
views
Using super in overriden initialize [duplicate]
Why I not get 'init' string ?
class Dwa
attr_reader :nazwa
def initialize()
puts 'init'
@nazwa = "dwa"
end
end
class Dwa #open this same object definition
def initialize()
...
0
votes
1
answer
336
views
Atlassian 1time TOTP - Java Implementation
I was attempting to implement this TOTP verification library created by Atlassian using java 1.8:
Atlassian 1time totp library
If I create a DefaultTOTPService, when I try to call any of its methods ...
1
vote
2
answers
74
views
double rendering after super is called in devise
class CustomSessionsController < DeviseTokenAuth::SessionsController
def create
binding.pry
super
confirmed = true
binding.pry
if current_user.present? && confirmed
...
0
votes
1
answer
58
views
How to access Father's variable name from Child when both variables have same name?
I have this code:
class Father():
def __init__(self,name):
self.name = name
class Child(Father):
def __init__(self,nombre):
Father.__init__(self,'a')
self....
0
votes
2
answers
55
views
Access a method from outside AJAX XMLHttpRequest with custom element [duplicate]
I have this custom HTML element causing me trouble. Down in the StaffList connectedCallback() function, i have to call and outside function of the parrent but the super keyword for addStaff() is ...
0
votes
1
answer
27
views
Identical **kwargs, but one raising "cannot convert dictionary update sequence element #0 to a sequence"
I have a very weird issue with dict inheritance. I want to be able to pass custom objects in an instance of the dict object, so I made a custom __new__ method to format these objects so they are ...
0
votes
1
answer
44
views
How to declare default member values in Java that are passed to super class but cannot be inline
I have code that I think is using static members incorrectly.
An example is below. Variable types and names might not make sense.
public class subclass extends superclass {
private static Boolean ...
1
vote
1
answer
73
views
super() can't increment the class variable of parent class but it updates parent class' class dictionary
I am encountering a weird problem on this following code snippet:
class Magical_SportsPerson:
database = {}
playerNo = 0
def __init__(self,name,team,jerseyNo):
self.name = name
...
0
votes
1
answer
91
views
TypError 4 instead of expected 3 arguments in super().__init_ call
Error Message
I got this message
File ...
super().__init__(self, self.event_pattern, stm)
TypeError: RegExpTokenizer.__init__() takes 3 positional arguments but 4 were given
The Code
class ...
0
votes
0
answers
48
views
Super() function error while converting checkpoint to TorchScript `torch.jit.script(classifier)`
I am trying torch.jit.script(classifier) but I am getting super() function error. I tried the solutions previously available but they are not working for me.
Here is my class where I am using super() ...
1
vote
2
answers
399
views
How does a subclass' call to its superclass' constructor assign values to the fields it inherits from the superclass?
I've been trying to understand this for a while and just can't seem to wrap my head around it.
This is what I think I know so far.
If class A extends class B, it must, either implicitly, or ...
0
votes
1
answer
51
views
Dart super-initializer constructor with private members
I'm currently learning Dart and have just written a class which extends a Base and uses the "super.* syntax" to initialize it. The member variable of the base which gets initialized is ...
1
vote
3
answers
153
views
How to best pass and merge sub type specific parameters to super at construction time?
I have a main class named Rule with a param attribute and several subclasses as example:
class Rule {
param = {}
constructor (param) {
// here I want to add the logic to ...
0
votes
1
answer
88
views
Automate parameters passing to super()
I have a parent class such as:
class Animal {
constructor({name, color}) {
// Does something with name and color.
}
}
Then I have many classes that extend Animal. For example:
class Lion ...
1
vote
4
answers
158
views
Overwrite call in javascript object
I am a newbie in JavaScript, trying to extend class variable prototype without inheritance
class Z{
constructor(){}
a(){console.log('a')}
get b(){console.log('b')}
c(){console.log('c')...
2
votes
2
answers
83
views
Using super keyword
Can someone please explain to me why this code gives me an ArgumentError yet when using super without arguments ruby automatically passes the arguments that were inherited from the superclass or am I ...
0
votes
0
answers
47
views
Python: want to get grandparents method result
I'm working with airflow and want to use SlackAPIOperator.
I want to return the result of execute method in SlakAPIOperator but original code does not return it.
So I inherited the Operator and ...
-1
votes
1
answer
114
views
multiple values for argument pass through
I don't understand the error linked in this post. why do I have to pass the variable level straight as a string into super().__init__ instead of a variable with a default string value for it to work? ...
0
votes
2
answers
33
views
Question about how python super access base class methods
Im still alittle unsure how python super works in the below context. If I have the below code running super().values_from_datadict() Is that to say that values_from_datadict() is a function that is ...
0
votes
1
answer
41
views
"SyntaxError: 'super' keyword unexpected here" calling method in ES6 class
class Foo {
go() {
console.log('Foo.go');
}
}
class Bar extends Foo {
go() {
console.log('Bar.go');
super(); // SyntaxError: 'super' keyword unexpected here
}
}...
1
vote
1
answer
2k
views
Python TypeError: .__init__() takes 1 positional argument but 4 were given , problem with super()
I am facing a TypeError for the below code:
class Student:
def __init__(self, name,age,subject):
self.name = name
self.age = age
self.subject = subject
def subjchoosen(...
1
vote
1
answer
631
views
Python __init__() missing 1 required positional argument
class Base:
def __init__(self, x, y, *args, **kwargs):
pass
class A(Base):
def __init__(self, x, y, z, *args, **kwargs):
super().__init__(x, y, *args, **kwargs)
class B(...
-3
votes
1
answer
36
views
Assign parent 's instance variable by using super keyword in Java
I have 2 class in Java
1. public class A {
2. public int i = 1;
3. }
4.
5. public class B extends A {
6. int i = 2;
7. public void print() {
8. super.i = 3;
9. A obj = new ...
1
vote
0
answers
43
views
Adding a new attribute to super class of plotly Annotation object?
Error message
After creating a super class that contains 1 additional attribute than the original Annotation class from Plotly, I am receiving error:
File "/home/name/git/snn/snncompare/src/...