About 226,000 results
Open links in new tab
  1. Python calling method in class - Stack Overflow

    Dec 30, 2012 · I'm trying to call a method in a class. I don't know what 'self' refers to, and what is the correct procedure to call such a method inside a class and outside a class. Could …

  2. Calling one method from another within same class in Python

    I was trying to pass a value from one method to another within the class. Because in my code, "if" is calling class's method on_any_event that in return should call my another method …

  3. Python __call__ special method practical example

    Apr 29, 2011 · Here's an example of where __call__ is used in practice: in pytorch, when defining a neural network (call it class MyNN(nn.Module) for example) as a subclass of …

  4. python - Call Class Method From Another Class - Stack Overflow

    Apr 17, 2022 · class A(object): def method1(self, a, b, c): # foo method = A.method1 method is now an actual function object. that you can call directly (functions are first class objects in …

  5. Call a Python method by name - Stack Overflow

    Aug 19, 2010 · Here is a more generalized version using Python decorators. You can call by short or long name. I found it useful when implementing CLI with short and long sub commands.

  6. How do I call a parent class's method from a child class in Python?

    Adam's has the benefit of showing both Python2 and Python3 forms. While this example works with both versions, the "new-style class" business and the arguments to super() are artifacts of …

  7. python - How does __call__ actually work? - Stack Overflow

    Sep 30, 2015 · If tp_call is not NULL, it calls through that, with the args and kwargs structures that were also passed to PyObject_Call. When a class defines a __call__ method, that sets up the …

  8. What is the difference between __init__ and __call__?

    Mar 12, 2012 · __init__ is a special method in Python classes, it is the constructor method for a class. It is called whenever an object of the class is constructed or we can say it initialises a …

  9. python - Calling a function of a module by using its name (a string ...

    Jun 4, 2022 · This method with globals/locals is good if the method you need to call is defined in the same module you are calling from. – Joelmob Commented Oct 9, 2014 at 21:36

  10. python - __call__ method of type class - Stack Overflow

    However, if the the class itself is derived from "type" - i.e., it is the instantiation of a "new" class, extra steps are taken: The special value of the magic __class__ variable is filled in any of the …

Refresh