Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created August 25, 2018 04:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/a517c4693665dea982eab05e103489cd to your computer and use it in GitHub Desktop.
Save Fhernd/a517c4693665dea982eab05e103489cd to your computer and use it in GitHub Desktop.
Invocación de función con diferente número de argumentos al requerido. OrtizOL.
from functools import partial
def sumar(a, b, c, d):
return a + b + c + d
# Producen error:
# sumar(2, 3, 4)
# sumar(7, 11)
# Uso de la función `partial`:
sumar1 = partial(sumar, 1)
sumar2 = partial(sumar, 3, 5)
print(sumar1(2, 3, 4))
print(sumar2(7, 11))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment