1

What would be the difference between x.func() and func(x)? Thanks!

The shape
  • 359
  • 3
  • 10

1 Answers1

3

@flakes answered your question, but if you want to see what it looks like implementation-wise it is something like this:

def func(x):
    print("func(x) calls function func passing x as a parameter.")

class X:
    def func(self):
        print("x.func() calls the method func on x w/ no parameters.")
x = X()

func(x)

x.func()

Output:

func(x) calls function func passing x as a parameter.
x.func() calls the method func on x w/ no parameters.
rhurwitz
  • 2,557
  • 2
  • 10
  • 18