2

See the code below

class HelloWorld:
    def print(self):
        print "Hello World"

Is HelloWorld.print(self) called a method or a function in Python?

2 Answers 2

8

They are referred to as class methods or instance methods.

Sign up to request clarification or add additional context in comments.

1 Comment

Sometimes the simplest answer is the best answer.
2

Just to add to Jakob's clear answer, in languages like Python there is no requirement that everything lives within a class, unlike (say) Java. So whereas in Java every function is a method, in Python this isn't true: many or even most functions aren't part of a class. That's why it makes sense to have this terminology distinction between methods and functions.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.