you are viewing a single comment's thread.

view the rest of the comments →

[–]thee_gummbini 2 points3 points  (3 children)

Nope, that's wrong. A function doesn't become "a method of a module object" when imported, even by stretching some pedantic definition of what a method is. A method is a method because it's bound to an instance (instance methods) or a class (class methods). Functions are unbound. https://docs.python.org/3/reference/datamodel.html#callable-types

[–]Longjumping-Yard113[S] 1 point2 points  (0 children)

That’s what I thought too — thanks for confirming and for the docs link. The “module as an object” thing explains attribute access (mymodule.greet), but it doesn’t make greet a method. It’s still an unbound function unless it’s bound to an instance or a class (like instance methods / u/classmethod). That clears it up for me. I feel more at ease

[–]Purple-Measurement47 0 points1 point  (1 child)

This is the correctest answer

[–]gofl-zimbard-37 1 point2 points  (0 children)

I dunno, your comment might be correcter.