Calling an object of a method of a class within another method of the same class

lempy

I was trying to call the objects of a method in one of my classes within antoher method of the same class. Below you can find a small example of how I tried to do it:

class example_class():
    
    def some_method(self):
        #... calculate something ...
        a = 1 
        b = 2

    def second_method(self):
        call = self.some_method()
        c = call.a + call.b

If I do this, I get the error: "'NoneType' object has no attribute 'a'". I am sure this is a fearly basic problem, but I am using classes, objects and methods for the first time and would really appreciate the help!

Thank you in advance and stay safe!

Ricardo
class example_class():

    def some_method(self):
        #... calculate something ...
        self.a = 1 
        self.b = 2

    def second_method(self):
        # call = self.some_method()
        c = self.a + self.b

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Calling a method within the same class

From Java

Calling one method from another within same class in Python

From Javascript

Calling a method from another method in the same class

From Java

Calling a method inside another method in same class

From Dev

Calling a constructor from method within the same class

From Java

OOP: Calling a public method within the same class

From Java

Calling a method on an Object from within a Class vs from within a method

From Dev

Calling method of another parent of the same class

From Dev

Calling an object and its method from another object class method

From Dev

javascript why calling a method from another method in the same class need this?

From Dev

Error with calling a method from another method in the same class

From Dev

Calling a method from another method inside the same class using getattr

From Dev

Javascript - How to call a method in another method within the same class

From Dev

Not able to call method within another method of the same class JS

From Dev

Mockito - Verifying if a method calls another method within the same class

From Dev

Problems calling a method within the same class in f#

From Java

Repaint() method calling in another class

From Dev

Typescript: Calling a "method" of another class

From Dev

calling method in another class in php

From Dev

Calling method through another class

From Dev

Is there a way to transfer a value of an int from one object to another within the same class via method in c#

From Dev

Using a python method in a class to check variables are the same in another class object

From Dev

Calling a list from one method to another in the same class in Python

From Dev

@Transactional method calling a method in the same class

From Java

Calling method of Another class from run() method

From Dev

Accessing variable from another method within the same class

From Dev

Calling a class from another class with main method

From Dev

Calling a method from one class in another class

From Dev

Store an instance of a class within another class method

Related Related

  1. 1

    Calling a method within the same class

  2. 2

    Calling one method from another within same class in Python

  3. 3

    Calling a method from another method in the same class

  4. 4

    Calling a method inside another method in same class

  5. 5

    Calling a constructor from method within the same class

  6. 6

    OOP: Calling a public method within the same class

  7. 7

    Calling a method on an Object from within a Class vs from within a method

  8. 8

    Calling method of another parent of the same class

  9. 9

    Calling an object and its method from another object class method

  10. 10

    javascript why calling a method from another method in the same class need this?

  11. 11

    Error with calling a method from another method in the same class

  12. 12

    Calling a method from another method inside the same class using getattr

  13. 13

    Javascript - How to call a method in another method within the same class

  14. 14

    Not able to call method within another method of the same class JS

  15. 15

    Mockito - Verifying if a method calls another method within the same class

  16. 16

    Problems calling a method within the same class in f#

  17. 17

    Repaint() method calling in another class

  18. 18

    Typescript: Calling a "method" of another class

  19. 19

    calling method in another class in php

  20. 20

    Calling method through another class

  21. 21

    Is there a way to transfer a value of an int from one object to another within the same class via method in c#

  22. 22

    Using a python method in a class to check variables are the same in another class object

  23. 23

    Calling a list from one method to another in the same class in Python

  24. 24

    @Transactional method calling a method in the same class

  25. 25

    Calling method of Another class from run() method

  26. 26

    Accessing variable from another method within the same class

  27. 27

    Calling a class from another class with main method

  28. 28

    Calling a method from one class in another class

  29. 29

    Store an instance of a class within another class method

HotTag

Archive