Latest Questions tagged Class

Browse all latest questions tagged Class

51
Votes
Published 06 Sep, 2022
Java - Multiple .class files generated for a class?

Out of curiosity, why are sometimes multiple Java .class files generated for a class after compilation? For example, my application has six classes. For one class, a total of 10 .class files has been...

68
Votes
Published 20 Aug, 2022
Python - Is it possible to dynamically inherit from a class that is only known at runtime in python?

I want to expand the class Foo by the class Bar, the issue that I have is that I can't expand it in the usual way (class Foo(Bar)) because the class Bar is somewhat dynamically generated. I made this...

606
Votes
Published 06 May, 2022
Python - How to print instances of a class using print()?

I am learning the ropes in Python. When I try to print an object of class Foobar using the print() function, I get an output like this: <__main__.Foobar instance at 0x7ff2a18c> Is there a way...

24
Votes
Published 24 Apr, 2022
Javascript - TypeScript static classes

I wanted to move to TypeScript from traditional JS because I like the C#-like syntax. My problem is that I can't find out how to declare static classes in TypeScript. In C#, I often use static classe...

96
Votes
Published 10 Aug, 2022
Jquery - jQuery if hasclass then function

This is an animation which should only fire if the div rip_tab has the class 'rip_tab_ripped', which is applied after the div is clicked on. However, the animation is firing even before the rip_tab_ri...

694
Votes
Published 06 May, 2022
Python - What is the difference between __init__ and __call__?

I want to know the difference between __init__ and __call__ methods. For example: class test: def __init__(self): self.a = 10 def __call__(self): b = 20

56
Votes
Published 31 Aug, 2022
Java - How is abstract class different from concrete class?

I understand WHY we need Abstract Class in Java - to create sub-classes. But the same can be achieved by concrete class. e.g. Class Child extends Parent. Here Parent can very well be abstract & co...

103
Votes
Published 31 Aug, 2022
Python - python class instance variables and class variables

I'm having a problem understanding how class / instance variables work in Python. I don't understand why when I try this code the list variable seems to be a class variable class testClass(): lis...

23
Votes
Published 01 May, 2022
Python - Python: one single module (file .py) for each class?

I've started programming in python 2 weeks ago. I'm making a separate file (module) for each class as I've done before in languages like Java or C#. But now, seeing tutorials and code from other peopl...

23
Votes
Published 25 Aug, 2022
Python - Graph implementation using python adding an edge

The teststring represents the structure given in euler project problem 18. Trying to solve it using graph theory. The graph structure I am trying to create is as below. Every number given in the strin...

120
Votes
Published 31 May, 2022
Python - staticmethod and recursion?

I have following code: class Foo(object): def __init__(self): baz=self.bar(10) @staticmethod def bar(n): if n==0: return 'bar' else: retur...

23
Votes
Published 08 Jul, 2022
Jquery - Find closest table row element with a particular class attribute looking in reverse from current element

I have a JqGrid and want to toggle automatically the display of the last edited row/group when returning to the view/page containing the grid. The process I have is Write the last edited OrderId to...

25
Votes
Published 18 Aug, 2022
Python - Python find the type of a function

I have a variable f. How can I determine its type? Here is my code, typed into a Python interpreter, showing that I get an error using the successful pattern of the many examples I have found with Goo...

35
Votes
Published 13 Aug, 2022
Python - How to implement a binary search tree in Python?

This is what I've got so far but it is not working: class Node: rChild,lChild,data = None,None,None def __init__(self,key): self.rChild = None self.lChild = None self...

19
Votes
Published 15 Jun, 2022
Python - Classname same as file/module name leads to inheritance issue

My code worked fine when it was all in one file. Now, I'm splitting up classes into different modules. The modules have been given the same name as the classes. Perhaps this is a problem, because Main...