Are classes necessary for creating methods (defs) in Python?

Are classes necessary for creating methods (defs) in Python?

+3
source share
3 answers

No. However def, which are not part of the class are usually called functions, not methods, but they are exactly the same, except that they are not related to the class.

def myFunction(arg1, arg2):
    # do something here
+12
source

No, you can create functions using defwithout having to transfer them to classes.

Java #, , Python: , , Python, , , , ..

+2

"".

, , Python, Python . ( - Python). . - , .

, , . , Python: __dict__. ( , , , , , , .)

[. , , , , .]

0

Source: https://habr.com/ru/post/1743890/


All Articles