2

In JavaScript I can use arguments in a function like:

function a (){
   console.log(arguments);
}

a(1,2,3,4,5,6) // Arguments(6) [1, 2, 3, 4, 5, 6, callee: ƒ, 
                Symbol(Symbol.iterator): ƒ]

Do functions in Python have an object like JavaScript's arguments?

I tried to use arguments in python (like in JavaScript) but I am getting an error, maybe there is an object in python but it is not called 'arguments'?

How can I get all the arguments of a function in python ?

klugjo
  • 19,422
  • 8
  • 57
  • 75
TTTC
  • 21
  • 1

1 Answers1

4

In Python to have access to arguments like in JS you would do following:

def funcA(*args):
   print(args)

You can use any name you want in place of args

funcA(1,2,3) # prints (1, 2, 3)
Muhammet Enginar
  • 508
  • 6
  • 14
Val
  • 196
  • 7