🌐
GeeksforGeeks
geeksforgeeks.org › python › difference-method-function-python
Difference between Method and Function in Python - GeeksforGeeks
July 11, 2025 - Know more about Python min() or max() function. ... Simply, function and method both look similar as they perform in almost similar way, but the key difference is the concept of 'Class and its Object'.
🌐
Dontusethiscode
dontusethiscode.com › blog › 2025-03-05_funcmethods.html
Python: functions vs methods
But understanding how methods bind—and when they don't—is crucial when working with advanced patterns like delegation, mixins, or direct super-class method calls. In Python, the key difference between a function and a method is whether it's tied to an object.
Discussions

In Python, what is the difference between a method and a function?
On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge. If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options: Limiting your involvement with Reddit, or Temporarily refraining from using Reddit Cancelling your subscription of Reddit Premium as a way to voice your protest. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/learnprogramming
71
200
April 8, 2024
Difference between functions and methods in Python
Greg Kitchin is having issues with: I've just started the new Python course, and a little confused over how a function and method are different. The way they're described, they so... More on teamtreehouse.com
🌐 teamtreehouse.com
1
December 12, 2015
Python method vs function - Stack Overflow
I am seeking for a confirmation if my thinking is correct in terms of Python method vs function: A method is a part of a class. A function is defined outside of a class. so e.g. class FooBar(ob... More on stackoverflow.com
🌐 stackoverflow.com
Difference between methods and functions, in Python compared to C++ - Stack Overflow
I'm doing Code Academy's tutorials on Python, and I'm a bit confused about the definition of method and function. From the tutorial: You already know about some of the built-in functions we've us... More on stackoverflow.com
🌐 stackoverflow.com
🌐
W3Schools
w3schools.com › python › python_functions.asp
Python Functions
Python Examples Python Compiler ... Python Study Plan Python Interview Q&A Python Training ... A function is a block of code which only runs when it is called. A function can return data as a result....
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-functions
Python Functions - GeeksforGeeks
Mutable objects like lists can be modified inside functions. Immutable objects like integers and strings remain unchanged. ... def myFun(x): x[0] = 20 b = [10, 11, 12, 13] myFun(b) print(b) def myFun2(x): x = 20 a = 10 myFun2(a) print(a) ... myFun(x) modifies the first element of the list and lists are mutable, so the original list changes. myFun2(x) assigns a new value to x. Integers are immutable, so the original value of a remains unchanged. Note: Python uses pass-by-object-reference, where functions receive references to objects instead of actual copies.
Published: 3 weeks ago
🌐
DataFlair
data-flair.training › blogs › python-method-and-function
Difference Between Method and Function in Python - DataFlair
April 14, 2026 - Because a method is linked to its object, Python silently passes that object as the first argument—commonly named self in class definitions. This bond lets the method read or modify the object’s own data, whereas a plain function can only access what you hand it directly.
🌐
Srinimf
srinimf.com › 2024 › 10 › 10 › function-vs-method-what-is-the-difference-in-python
Function Vs. Method: What is the Difference in Python – Srinimf
October 15, 2024 - Functions are independent code blocks, while methods are functions tied to classes, requiring an instance for invocation and access to object attributes.
🌐
DEV Community
dev.to › simoneintech › function-vs-method-in-python-3335
Function vs Method in Python - DEV Community
May 15, 2023 - In other words, a method is a function that is called on a specific object. Methods are used to manipulate an object's state and behavior. Here is an example of a method in Python:
Find elsewhere
🌐
DataScience+
datascienceplus.com › home › programming › methods vs. functions in python
Methods vs. Functions in Python – DataScience+
August 11, 2020 - But methods cannot be called by its name only we need to invoke the class by reference of that class in which it is defined, that is, the method is defined within a class and hence they are dependent on that class. A function is an organized block of statements or reusable code that is used to perform a single/related action. Python programming three types of functions:
🌐
Codingem
codingem.com › home › python methods vs functions — what’s the difference?
Python Methods vs Functions — What's the Difference?
October 20, 2022 - The difference between a function and a method in Python is that a method is implemented inside a class. A function is implemented outside.
🌐
Python
wiki.python.org › moin › FromFunctionToMethod
From Function to Method
This is itself a callable object; calling it mostly injects the instance as the first item in the argument list and returns the result of calling the wrapped function object. A (naive) implementation of the whole thing might look like this: class method(object): def __init__(self, func, instance, cls): self.im_func = func self.im_self = instance self.im_class = cls def __call__(self, *args, **kw): # XXX : all sanity checks removed for readability if self.im_self: args = (self.im_self,) + args return self.im_func(*args, **kw) class function(object): def __get__(self, instance, cls): return method(self, instance, cls)
🌐
Medium
medium.com › @rajputgajanan50 › difference-between-function-and-method-in-python-e836b346985a
Difference between function and method in Python | by Gajanan Rajput💚 | Medium
April 20, 2024 - In this post, we’ll explore what functions and methods are, how they differ, and when to use each, using a clear comparative table and practical examples. In Python, a function is a block of code that is designed to perform a specific task. ...
🌐
Study.com
study.com › computer science courses › general computer science lessons
Method vs. Function in Python | Overview, Differences & Examples | Study.com
October 30, 2025 - Methods are defined within a class and are designed to access or modify the attributes of the object upon which they are called. If a function exists outside of a class, it is simply a standalone function, not a method.
Top answer
1 of 2
10

Yes. To be clear, methods are functions, they are simply attached to the class, and when that function is called from an instance it gets that instance passed implicitly as the first argument automagically*. It doesn't actually matter where that function is defined. Consider:

class FooBar:
    def __init__(self, n):
        self.n = n
    def foo(self):
        return '|'.join(self.n*['foo'])


fb = FooBar(2)

print(fb.foo())

def bar(self):
    return '*'.join(self.n*['bar'])

print(bar(fb))

FooBar.bar = bar

print(fb.bar())

*I highly recommend reading the descriptor HOWTO. Spoiler alert, Functions are descriptors. This is how Python magically passes instances to methods (that is, all function objects are descriptors who's __get__ method passes the instance as the first argument to the function itself when accessed by an instance on a class!. The HOWTO shows Python implementations of all of these things, including how you could implement property in pure Python!

2 of 2
5

Actually, methods and functions in Python are exactly the same thing!

It matters not one bit where it is defined. What matters is how it is looked up.

def defined_outside(*args):
    return args

class C:

    def defined_inside(*args):
        return args

C.defined_outside = defined_outside
defined_inside = C.defined_inside

instance = C()

print(         defined_inside (1,2))
print(         defined_outside(1,2))
print(instance.defined_inside (1,2))
print(instance.defined_outside(1,2))

which gives the output

(1, 2)
(1, 2)
(<__main__.C object at 0x7f0c80d417f0>, 1, 2)
(<__main__.C object at 0x7f0c80d417f0>, 1, 2)

(This will only work in Python 3: Two of these will produce a TypeError in Python 2.)

What is important to notice about the output is that, in the first two cases, the functions receive two arguments: 1 and 2. In the last two cases they receive three arguments: instance, 1 and 2.

In the cases where instance is passed to the function, the function is behaving like a method. In the cases where instance is not passed in, the function is behaving like a plain function. But notice that both behaviours are exhibited by both the function which was defined inside the classe and the one which was defined outside the class.

What matters is how the function was looked up. If it was looked up as an attribute of an instance of a class, then the function behaves like a method; otherwise it behaves like a free function.

[Incidentally, this binding behaviour only works for pure Python functions; it does not work for functions defined using the Python/C API. The latter always behave like functions and never like methods:

C.dir = dir
instance.dir()

will give you a directory of the global scope, not of instance, indicating that dir recived zero arguments, rather that receiving instance as an argument. ]

🌐
Python Geeks
pythongeeks.org › python geeks › learn python › python methods vs functions
Python Methods vs Functions - Python Geeks
June 8, 2021 - We have only methods in Java and only functions in C but in Python, we have both functions and methods.
🌐
Real Python
realpython.com › ref › glossary › method
method | Python Glossary – Real Python
In Python, a method is a function that is associated with a particular object or class.
🌐
Python
docs.python.org › 3 › builtins › functions.html
Built-in Functions — Python 3.14.8 documentation
A class method receives the class as an implicit first argument, just like an instance method receives the instance. To declare a class method, use this idiom: ... The @classmethod form is a function decorator – see Function definitions for details.
Top answer
1 of 6
57

Needs Attention: This answer seems to be outdated. Check this

A function is a callable object in Python, i.e. can be called using the call operator (though other objects can emulate a function by implementing __call__). For example:

>>> def a(): pass
>>> a
<function a at 0x107063aa0>
>>> type(a)
<type 'function'>

A method is a special class of function, one that can be bound or unbound.

>>> class A:
...   def a(self): pass
>>> A.a
<unbound method A.a>
>>> type(A.a)
<type 'instancemethod'>

>>> A().a
<bound method A.a of <__main__.A instance at 0x107070d88>>
>>> type(A().a)
<type 'instancemethod'>

Of course, an unbound method cannot be called (at least not directly without passing an instance as an argument):

>>> A.a()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unbound method a() must be called with A instance as first argument (got nothing instead)

In Python, in most cases, you won't notice the difference between a bound method, a function, or a callable object (i.e. an object that implements __call__), or a class constructor. They all look the same, they just have different naming conventions. Under the hood, the objects may look vastly different though.

This means that a bound method can be used as a function, this is one of the many small things that makes Python so powerful

>>> b = A().a
>>> b()

It also means that even though there is a fundamental difference between len(...) and str(...) (the latter is a type constructor), you won't notice the difference until you dig a little deeper:

>>> len
<built-in function len>
>>> str
<type 'str'>
2 of 6
5

If you still don’t understand how methods work, a look at the implementation can perhaps clarify matters. When an instance attribute is referenced that isn’t a data attribute, its class is searched. If the name denotes a valid class attribute that is a function object, a method object is created by packing (pointers to) the instance object and the function object just found together in an abstract object: this is the method object. When the method object is called with an argument list, a new argument list is constructed from the instance object and the argument list, and the function object is called with this new argument list.

http://docs.python.org/2/tutorial/classes.html#method-objects

Read carefully this excerpt.

It means :

1) An instance doesn't really hold an object being a method that would be its attribute.
In fact, there is not at all a "method" attribute in the __dict__ of an instance (__dict__ is the namespace of an object)

2) The fact that an instance seems to have a "method" when a "method" attribute is called, is due to a process, not the presence of a method object inside the namespace of an instance

3) Also, there doesn't really exist a method object in the namespace of a class.

But there's a difference with an instance, because there must be somewhere something that leads to a real method object when such a call is done, must not ?

What is called a "method" attribute of a class, for easiness of wording, is in reality a function object being attribute in the namespace of the class.
That is to say, a pair (identifier of the function, function) is a member of the __dict__ of a class, and this attribute allows the intepreter to construct a method object when a method call is performed.

4) Again, the fact that a class seems to have a "method" when a "method" attribute is called, is due to a process, not to the presence of a method object inside the namespace of a class

EDIT I'm no more sure of that; see at the end

5) A method object (not "method" object; I mean the real object being really a method`, what is described in the excerpt) is created at the moment of the call, it doesn't exists before.
It is a kind of wrapper : it packs pointers to the instance object and the function object on which the method is based.

So, a method is based on a function. This function is for me the real attribute of the class holding the said "method", because this function really belongs to the namespace ( __dict__ ) of the class: this function is described as a <function ......> when the __dict__ is printed.
This function can be reached from the method object using the alias im_func or __func__ (see the below code)

.

I believe that these notions are not very commonly known and understood. But the following code proves what I said.

class A(object):
    def __init__(self,b=0):
        self.b = b
    print 'The __init__ object :\n',__init__

    def addu(self):
        self.b = self.b + 10
    print '\nThe addu object :\n',addu


print '\nThe A.__dict__  items :\n',
print '\n'.join('  {0:{align}11}  :  {1}'.format(*it,align='^')
                for it in A.__dict__.items())
a1 = A(101)
a2 = A(2002)

print '\nThe a1.__dict__  items:'
print '\n'.join('  {0:{align}11}  :  {1}'.format(*it,align='^')
                for it in a1.__dict__.items())

print '\nThe a2.__dict__  items:'
print '\n'.join('  {0:{align}11}  :  {1}'.format(*it,align='^')
                for it in a2.__dict__.items())

print '\nA.addu.__func__ :',A.addu.__func__
print id(A.addu.__func__),'==',hex(id(A.addu.__func__))
print

print 'A.addu :\n  ',
print A.addu,'\n  ',id(A.addu),'==',hex(id(A.addu))

print 'a1.addu :\n  ',
print a1.addu,'\n  ',id(a1.addu),'==',hex(id(a1.addu))
print 'a2.addu :\n  ',
print a2.addu,'\n  ',id(a2.addu),'==',hex(id(a2.addu))

a2.addu()
print '\na2.b ==',a2.b

print '\nThe A.__dict__  items :\n',
print '\n'.join('  {0:{align}11}  :  {1}'.format(*it,align='^')
                for it in A.__dict__.items())

result

The __init__ object :
<function __init__ at 0x011E54B0>

The addu object :
<function addu at 0x011E54F0>

The A.__dict__  items :
  __module__   :  __main__
     addu      :  <function addu at 0x011E54F0>
   __dict__    :  <attribute '__dict__' of 'A' objects>
  __weakref__  :  <attribute '__weakref__' of 'A' objects>
    __doc__    :  None
   __init__    :  <function __init__ at 0x011E54B0>

The a1.__dict__  items:
       b       :  101

The a2.__dict__  items:
       b       :  2002

A.addu.__func__ : <function addu at 0x011E54F0>
18765040 == 0x11e54f0

A.addu :
   <unbound method A.addu> 
   18668040 == 0x11cda08
a1.addu :
   <bound method A.addu of <__main__.A object at 0x00CAA850>> 
   18668040 == 0x11cda08
a2.addu :
   <bound method A.addu of <__main__.A object at 0x011E2B90>> 
   18668040 == 0x11cda08

a2.b == 2012

The A.__dict__  items :
  __module__   :  __main__
     addu      :  <function addu at 0x011E54F0>
   __dict__    :  <attribute '__dict__' of 'A' objects>
  __weakref__  :  <attribute '__weakref__' of 'A' objects>
    __doc__    :  None
   __init__    :  <function __init__ at 0x011E54B0>

.

EDIT

Something is troubling me and I don't know the deep innards of the subject:

The above code shows that A.addu , a1.addu and a2.addu are all the same method object, with a unique identity.
However A.addu is said an unbound method because it doesn't have any information concerning an particular instance,
and a1.addu and a2.addu are said bound methods because each one has information designating the instance that must be concerned by the operations of the method.
Logically, for me, that would mean that the method should be different for each of these 3 cases.

BUT the identity is the same for all three, and moreover this identity is different from the identity of the function on which the method is based.
It leads to the conclusion that the method is really an object living in the memory, and that it doesn't change from one call from an instance to another cal from another instance.

HOWEVER , printing the namespace __dict__ of the class, even after the creation of instances and the call of the "method" addu(), this namespace doesn't exposes a new object that could be identified to the method object different from the addu function.

What does it mean ?
It gives me the impression that as soon as a method object is created, it isn't destroyed, it lives in the memory (RAM).
But it lives hidden and only the processes that form the interpeter's functionning know how and where to find it.
This hidden object, the real method object, must have the ability to change the reference to the instance to which the function must be applied, or to reference None if it is called as an unbound method. That's what it seems to me, but it's only brain-storming hypothesis.

Does anybody know something on this interrogation ?


To answer to the question, it can be considered correct to call .upper and .lower functions , since in reality they are based on functionsas every method of a class.

However, the following result is special, probably because they are builtin methods/functions, not user's methods/functions as in my code.

x = 'hello'
print x.upper.__func__

result

    print x.upper.__func__
AttributeError: 'builtin_function_or_method' object has no attribute '__func__'