Python positional and keyword args

up:: Code
tags:: #Knowledge #coding #python

Arguments

related concepts:
currying a function

Functional languages have functions that take in arguments.
Some arguments are presumed to be there in an order; positional.
Others are accessible by key; keyword.

In python these are abstracted in order:
*args // the * acts almost as a pointer, it unpacks the array of args, and presupposes variable length
another example that's not just defining func(*args):

some_range = (2,6)
print(4 in range(*some_range)) # True

**kwargs // this unpacks a dictionary and puts each key: value individually into the call

Powered by Forestry.md