Python Forum

Full Version: Supplying 2 arguments to 3-argument function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
The first parameter is self, which is auto-populated with the current instance.
(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?
Maybe the parent is a different class, that only expects two parameters?

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