Python Forum
Supplying 2 arguments to 3-argument function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Supplying 2 arguments to 3-argument function
#1
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.
Reply
#2
The first parameter is self, which is auto-populated with the current instance.
Reply
#3
(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?
Reply
#4
Maybe the parent is a different class, that only expects two parameters?

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


Possibly Related Threads…
Thread Author Replies Views Last Post
  function arguments Curbie 2 512 Apr-30-2025, 05:23 PM
Last Post: Curbie
  mutable argument in function definition akbarza 1 1,287 Dec-15-2023, 02:00 PM
Last Post: deanhystad
  calling external function with arguments Wimpy_Wellington 6 3,115 Jul-05-2023, 06:33 PM
Last Post: deanhystad
Information How to take url in telegram bot user input and put it as an argument in a function? askfriends 0 2,471 Dec-25-2022, 03:00 PM
Last Post: askfriends
  i want to use type= as a function/method keyword argument Skaperen 9 3,836 Nov-06-2022, 04:28 AM
Last Post: Skaperen
  Regex - Pass Flags as a function argument? muzikman 6 6,296 Sep-06-2021, 03:43 PM
Last Post: muzikman
  'namespace' shorthand for function arguments? shadowphile 5 3,756 Aug-11-2021, 09:02 PM
Last Post: shadowphile
  Checking the number of arguments a function takes Chirumer 3 3,079 Jul-06-2021, 04:56 PM
Last Post: Chirumer
  Possible to dynamically pass arguments to a function? grimm1111 2 3,008 Feb-21-2021, 05:57 AM
Last Post: deanhystad
  How to use a tuple as an argument of a function zarox 5 9,657 Nov-14-2020, 08:02 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020