Changeset 49


Ignore:
Timestamp:
05/07/09 15:26:58 (4 years ago)
Author:
jjconti
Message:

Desempaquetando una Lista de Argumentos

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/traducidos/controlflow.rst

    r48 r49  
    439439.. _tut-arbitraryargs: 
    440440 
    441 Arbitrary Argument Lists 
    442 ------------------------ 
     441Listas de Argumentos Arbritrarios 
     442-------------------------------------------- 
    443443 
    444444.. index:: 
    445445  statement: *   
    446446 
    447 Finally, the least frequently used option is to specify that a function can be 
    448 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 arguments may occur. :: 
     447Finalmente, la opción menos frecuentemente usada es especificar que una función 
     448puede ser llamada con un número arbitrario de argumentos.  Estos argumentos serán 
     449organizados en una tupla. Antes del número variable de argumentos, cero o más  
     450argumentos normales pueden estar presentes.:: 
    451451 
    452452   def fprintf(file, template, *args): 
     
    456456.. _tut-unpacking-arguments: 
    457457 
    458 Unpacking Argument Lists 
    459 ------------------------ 
    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 arguments.  For instance, the built-in :func:`range` function expects separate 
    464 *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:: 
     458Desempaquetando una Lista de Argumentos 
     459---------------------------------------------------------- 
     460 
     461La situación inversaa ocurre cuando los argumentos ya están en una lista o tupla 
     462pero necesitan sen desempaquetados para llamar a una función que requiere  
     463argumentos posicionales separados. Por ejemplo, la función predefinida :func:`range`  
     464espera los argumentos *inicio* y *fin*.  Si no están disponibles en forma separada, 
     465se puede escribir la llamada a la función con el operador para desempaquetar  
     466argumentos de una lista o una tupla ``*``\:: 
    467467 
    468468   >>> range(3, 6)             # normal call with separate arguments 
     
    475475  statement: ** 
    476476 
    477 In the same fashion, dictionaries can deliver keyword arguments with the ``**``\ 
    478 -operator:: 
     477Del mismo modo, los diccionarios pueden entregar argumentos de palabra clave con el  
     478operador ``**``\:: 
    479479 
    480480   >>> def parrot(voltage, state='a stiff', action='voom'): 
Note: See TracChangeset for help on using the changeset viewer.