Python Forum
Supplying 2 arguments to 3-argument function - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Supplying 2 arguments to 3-argument function (/thread-4815.html)



Supplying 2 arguments to 3-argument function - valtih - Sep-10-2017

I have the following piece of code
		def visit(self, path, rootf, extraf): 
			return extraf(path, path.parent().visit(rootf, extraf))
I wonder how can it work if function visit takes 3 parameters but recursive call supplies only two.


RE: Supplying 2 arguments to 3-argument function - nilamo - Sep-10-2017

The first parameter is self, which is auto-populated with the current instance.


RE: Supplying 2 arguments to 3-argument function - valtih - Sep-10-2017

(Sep-10-2017, 04:55 PM)nilamo Wrote: The first parameter is self, which is auto-populated with the current instance.

I obviously understand this when count only 3 arguments out of total 4: self, path, rootf and extraf. I see that recursion supplies only last two but not path. Can you explain that?


RE: Supplying 2 arguments to 3-argument function - nilamo - Sep-10-2017

Maybe the parent is a different class, that only expects two parameters?

Otherwise, it wouldn't run, since there's no default values.