Changeset 49
- Timestamp:
- 05/07/09 15:26:58 (4 years ago)
- File:
-
- 1 edited
-
trunk/traducidos/controlflow.rst (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/traducidos/controlflow.rst
r48 r49 439 439 .. _tut-arbitraryargs: 440 440 441 Arbitrary Argument Lists442 ------------------------ 441 Listas de Argumentos Arbritrarios 442 -------------------------------------------- 443 443 444 444 .. index:: 445 445 statement: * 446 446 447 Final ly, the least frequently used option is to specify that a function can be448 called with an arbitrary number of arguments. These arguments will be wrapped 449 up in a tuple. Before the variable number of arguments, zero or more normal 450 argument s may occur.::447 Finalmente, la opción menos frecuentemente usada es especificar que una función 448 puede ser llamada con un número arbitrario de argumentos. Estos argumentos serán 449 organizados en una tupla. Antes del número variable de argumentos, cero o más 450 argumentos normales pueden estar presentes.:: 451 451 452 452 def fprintf(file, template, *args): … … 456 456 .. _tut-unpacking-arguments: 457 457 458 Unpacking Argument Lists459 ------------------------ 460 461 The reverse situation occurs when the arguments are already in a list or tuple 462 but need to be unpacked for a function call requiring separate positional 463 argument s. For instance, the built-in :func:`range` function expects separate464 *start* and *stop* arguments. If they are not available separately, write the 465 function call with the ``*``\ -operator to unpack the arguments out of a list 466 or tuple::458 Desempaquetando una Lista de Argumentos 459 ---------------------------------------------------------- 460 461 La situación inversaa ocurre cuando los argumentos ya están en una lista o tupla 462 pero necesitan sen desempaquetados para llamar a una función que requiere 463 argumentos posicionales separados. Por ejemplo, la función predefinida :func:`range` 464 espera los argumentos *inicio* y *fin*. Si no están disponibles en forma separada, 465 se puede escribir la llamada a la función con el operador para desempaquetar 466 argumentos de una lista o una tupla ``*``\:: 467 467 468 468 >>> range(3, 6) # normal call with separate arguments … … 475 475 statement: ** 476 476 477 In the same fashion, dictionaries can deliver keyword arguments with the ``**``\ 478 -operator::477 Del mismo modo, los diccionarios pueden entregar argumentos de palabra clave con el 478 operador ``**``\:: 479 479 480 480 >>> def parrot(voltage, state='a stiff', action='voom'):
Note: See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/python-tutorial/chrome/site/your_project_logo.png)