Python Forum
Possible to dynamically pass arguments to a function?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Possible to dynamically pass arguments to a function?
#2
Nevermind, I figured it out.

color = [chess.BLACK, chess.WHITE]
square = [chess.A7, chess.C7]

a = 1

attackers = board.attackers(color[a], square[a])
If anybody else ever wants to do this, here's how I did it. It will accept a slice or an integer, but not an immutable object like a string, which was the problem I was having.

Thanks everyone.
Reply


Messages In This Thread
RE: Possible to dynamically pass arguments to a function? - by grimm1111 - Feb-21-2021, 05:44 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to pass encrypted pass to pyodbc script tester_V 0 958 Jul-27-2023, 12:40 AM
Last Post: tester_V
  calling external function with arguments Wimpy_Wellington 7 1,623 Jul-05-2023, 06:33 PM
Last Post: deanhystad
  Regex - Pass Flags as a function argument? muzikman 6 3,786 Sep-06-2021, 03:43 PM
Last Post: muzikman
  'namespace' shorthand for function arguments? shadowphile 5 2,712 Aug-11-2021, 09:02 PM
Last Post: shadowphile
  Checking the number of arguments a function takes Chirumer 3 2,270 Jul-06-2021, 04:56 PM
Last Post: Chirumer
  Why Pass Functions as arguments? muzikman 14 5,984 Jan-18-2021, 12:08 PM
Last Post: Serafim
  Function won't apply dynamically in timeseries illmattic 1 1,796 Jan-08-2021, 03:15 PM
Last Post: stullis
  how to pass arguments between pythons scripts? electricDesire 2 2,248 Oct-19-2020, 07:19 PM
Last Post: electricDesire
  Do I have to pass 85 variables to function? Milfredo 10 4,477 Sep-26-2020, 10:13 PM
Last Post: Milfredo
  Pass by object reference when does it behave like pass by value or reference? mczarnek 2 2,637 Sep-07-2020, 08:02 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

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