# Copyright (C) 2001-2020, Python Software Foundation # This file is distributed under the same license as the Python package. # Maintained by the python-doc-es workteam. # docs-es@python.org / # https://mail.python.org/mailman3/lists/docs-es.python.org/ # Check https://github.com/python/python-docs-es/blob/3.8/TRANSLATORS to # get the list of volunteers # msgid "" msgstr "" "Project-Id-Version: Python 3.8\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2020-05-05 12:54+0200\n" "PO-Revision-Date: 2020-06-24 23:14+0200\n" "Language-Team: python-doc-es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.8.0\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "Last-Translator: Cristián Maureira-Fredes \n" "Language: es\n" "X-Generator: Poedit 2.3\n" #: ../Doc/extending/embedding.rst:8 msgid "Embedding Python in Another Application" msgstr "Incrustando Python en Otra Aplicación" #: ../Doc/extending/embedding.rst:10 msgid "" "The previous chapters discussed how to extend Python, that is, how to extend " "the functionality of Python by attaching a library of C functions to it. It " "is also possible to do it the other way around: enrich your C/C++ " "application by embedding Python in it. Embedding provides your application " "with the ability to implement some of the functionality of your application " "in Python rather than C or C++. This can be used for many purposes; one " "example would be to allow users to tailor the application to their needs by " "writing some scripts in Python. You can also use it yourself if some of the " "functionality can be written in Python more easily." msgstr "" "Los capítulos anteriores discutieron cómo extender Python, es decir, cómo " "extender la funcionalidad de Python al adjuntarle una biblioteca de " "funciones C. También es posible hacerlo al revés: enriquezca su aplicación C/" "C++ incrustando Python en ella. La incrustación proporciona a su aplicación " "la capacidad de implementar parte de la funcionalidad de su aplicación en " "Python en lugar de C o C++. Esto se puede usar para muchos propósitos; Un " "ejemplo sería permitir a los usuarios adaptar la aplicación a sus " "necesidades escribiendo algunos scripts en Python. También puede usarlo " "usted mismo si parte de la funcionalidad se puede escribir en Python más " "fácilmente." #: ../Doc/extending/embedding.rst:20 msgid "" "Embedding Python is similar to extending it, but not quite. The difference " "is that when you extend Python, the main program of the application is still " "the Python interpreter, while if you embed Python, the main program may have " "nothing to do with Python --- instead, some parts of the application " "occasionally call the Python interpreter to run some Python code." msgstr "" "Incrustar Python es similar a extenderlo, pero no del todo. La diferencia es " "que cuando extiende Python, el programa principal de la aplicación sigue " "siendo el intérprete de Python, mientras que si incrusta Python, el programa " "principal puede no tener nada que ver con Python --- en cambio, algunas " "partes de la aplicación ocasionalmente llaman al Intérprete de Python para " "ejecutar algún código de Python." #: ../Doc/extending/embedding.rst:26 msgid "" "So if you are embedding Python, you are providing your own main program. " "One of the things this main program has to do is initialize the Python " "interpreter. At the very least, you have to call the function :c:func:" "`Py_Initialize`. There are optional calls to pass command line arguments to " "Python. Then later you can call the interpreter from any part of the " "application." msgstr "" "Entonces, si está incrustando Python, está proporcionando su propio programa " "principal. Una de las cosas que tiene que hacer este programa principal es " "inicializar el intérprete de Python. Como mínimo, debe llamar a la función :" "c:func:`Py_Initialize`. Hay llamadas opcionales para pasar argumentos de " "línea de comandos a Python. Luego, puede llamar al intérprete desde " "cualquier parte de la aplicación." #: ../Doc/extending/embedding.rst:32 msgid "" "There are several different ways to call the interpreter: you can pass a " "string containing Python statements to :c:func:`PyRun_SimpleString`, or you " "can pass a stdio file pointer and a file name (for identification in error " "messages only) to :c:func:`PyRun_SimpleFile`. You can also call the lower-" "level operations described in the previous chapters to construct and use " "Python objects." msgstr "" "Hay varias formas diferentes de llamar al intérprete: puede pasar una cadena " "que contiene declaraciones de Python a :c:func:`PyRun_SimpleString`, o puede " "pasar un puntero de archivo estándar y un nombre de archivo (solo para " "identificación en mensajes de error) a :c:func:`PyRun_SimpleFile`. También " "puede llamar a las operaciones de nivel inferior descritas en los capítulos " "anteriores para construir y usar objetos de Python." #: ../Doc/extending/embedding.rst:42 msgid ":ref:`c-api-index`" msgstr ":ref:`c-api-index`" #: ../Doc/extending/embedding.rst:42 msgid "" "The details of Python's C interface are given in this manual. A great deal " "of necessary information can be found here." msgstr "" "Los detalles de la interfaz C de Python se dan en este manual. Una gran " "cantidad de información necesaria se puede encontrar aquí." #: ../Doc/extending/embedding.rst:49 msgid "Very High Level Embedding" msgstr "Incrustación de muy alto nivel" #: ../Doc/extending/embedding.rst:51 msgid "" "The simplest form of embedding Python is the use of the very high level " "interface. This interface is intended to execute a Python script without " "needing to interact with the application directly. This can for example be " "used to perform some operation on a file. ::" msgstr "" "La forma más simple de incrustar Python es el uso de la interfaz de muy alto " "nivel. Esta interfaz está diseñada para ejecutar un script de Python sin " "necesidad de interactuar directamente con la aplicación. Esto puede usarse, " "por ejemplo, para realizar alguna operación en un archivo. ::" #: ../Doc/extending/embedding.rst:78 msgid "" "The :c:func:`Py_SetProgramName` function should be called before :c:func:" "`Py_Initialize` to inform the interpreter about paths to Python run-time " "libraries. Next, the Python interpreter is initialized with :c:func:" "`Py_Initialize`, followed by the execution of a hard-coded Python script " "that prints the date and time. Afterwards, the :c:func:`Py_FinalizeEx` call " "shuts the interpreter down, followed by the end of the program. In a real " "program, you may want to get the Python script from another source, perhaps " "a text-editor routine, a file, or a database. Getting the Python code from " "a file can better be done by using the :c:func:`PyRun_SimpleFile` function, " "which saves you the trouble of allocating memory space and loading the file " "contents." msgstr "" "La función :c:func:`Py_SetProgramName` debe llamarse antes de :c:func:" "`Py_Initialize` para informar al intérprete sobre las rutas a las " "bibliotecas de tiempo de ejecución de Python. A continuación, el intérprete " "de Python se inicializa con :c:func:`Py_Initialize`, seguido de la ejecución " "de un script Python codificado que imprime la fecha y la hora. Luego, la " "llamada :c:func:`Py_FinalizeEx` cierra el intérprete, seguido por el final " "del programa. En un programa real, es posible que desee obtener el script de " "Python de otra fuente, tal vez una rutina de editor de texto, un archivo o " "una base de datos. Obtener el código Python de un archivo se puede hacer " "mejor usando la función :c:func:`PyRun_SimpleFile`, que le ahorra la " "molestia de asignar espacio de memoria y cargar el contenido del archivo." #: ../Doc/extending/embedding.rst:93 msgid "Beyond Very High Level Embedding: An overview" msgstr "Más allá de la incrustación de muy alto nivel: una visión general" #: ../Doc/extending/embedding.rst:95 msgid "" "The high level interface gives you the ability to execute arbitrary pieces " "of Python code from your application, but exchanging data values is quite " "cumbersome to say the least. If you want that, you should use lower level " "calls. At the cost of having to write more C code, you can achieve almost " "anything." msgstr "" "La interfaz de alto nivel le permite ejecutar piezas arbitrarias de código " "Python desde su aplicación, pero el intercambio de valores de datos es " "bastante engorroso, por decir lo menos. Si lo desea, debe usar llamadas de " "nivel inferior. A costa de tener que escribir más código C, puede lograr " "casi cualquier cosa." #: ../Doc/extending/embedding.rst:100 msgid "" "It should be noted that extending Python and embedding Python is quite the " "same activity, despite the different intent. Most topics discussed in the " "previous chapters are still valid. To show this, consider what the extension " "code from Python to C really does:" msgstr "" "Cabe señalar que extender Python e incrustar Python es la misma actividad, a " "pesar de la intención diferente. La mayoría de los temas tratados en los " "capítulos anteriores siguen siendo válidos. Para mostrar esto, considere lo " "que realmente hace el código de extensión de Python a C:" #: ../Doc/extending/embedding.rst:105 msgid "Convert data values from Python to C," msgstr "Convierte valores de datos de Python a C," #: ../Doc/extending/embedding.rst:107 msgid "Perform a function call to a C routine using the converted values, and" msgstr "" "Realice una llamada de función a una rutina C usando los valores " "convertidos, y" #: ../Doc/extending/embedding.rst:109 msgid "Convert the data values from the call from C to Python." msgstr "Convierte los valores de datos de la llamada de C a Python." #: ../Doc/extending/embedding.rst:111 msgid "When embedding Python, the interface code does:" msgstr "Al incrustar Python, el código de interfaz hace:" #: ../Doc/extending/embedding.rst:113 msgid "Convert data values from C to Python," msgstr "Convierte valores de datos de C a Python," #: ../Doc/extending/embedding.rst:115 msgid "" "Perform a function call to a Python interface routine using the converted " "values, and" msgstr "" "Realice una llamada de función a una rutina de interfaz de Python utilizando " "los valores convertidos, y" #: ../Doc/extending/embedding.rst:118 msgid "Convert the data values from the call from Python to C." msgstr "Convierte los valores de datos de la llamada de Python a C." #: ../Doc/extending/embedding.rst:120 msgid "" "As you can see, the data conversion steps are simply swapped to accommodate " "the different direction of the cross-language transfer. The only difference " "is the routine that you call between both data conversions. When extending, " "you call a C routine, when embedding, you call a Python routine." msgstr "" "Como puede ver, los pasos de conversión de datos simplemente se intercambian " "para acomodar la dirección diferente de la transferencia de idiomas " "cruzados. La única diferencia es la rutina que llama entre ambas " "conversiones de datos. Al extender, llama a una rutina C, al incrustar, " "llama a una rutina Python." #: ../Doc/extending/embedding.rst:125 msgid "" "This chapter will not discuss how to convert data from Python to C and vice " "versa. Also, proper use of references and dealing with errors is assumed to " "be understood. Since these aspects do not differ from extending the " "interpreter, you can refer to earlier chapters for the required information." msgstr "" "Este capítulo no discutirá cómo convertir datos de Python a C y viceversa. " "Además, se supone que se entiende el uso adecuado de las referencias y el " "tratamiento de errores. Dado que estos aspectos no difieren de extender el " "intérprete, puede consultar los capítulos anteriores para obtener la " "información requerida." #: ../Doc/extending/embedding.rst:134 msgid "Pure Embedding" msgstr "Incrustación pura" #: ../Doc/extending/embedding.rst:136 msgid "" "The first program aims to execute a function in a Python script. Like in the " "section about the very high level interface, the Python interpreter does not " "directly interact with the application (but that will change in the next " "section)." msgstr "" "El primer programa tiene como objetivo ejecutar una función en un script " "Python. Al igual que en la sección sobre la interfaz de muy alto nivel, el " "intérprete de Python no interactúa directamente con la aplicación (pero eso " "cambiará en la siguiente sección)." #: ../Doc/extending/embedding.rst:141 msgid "The code to run a function defined in a Python script is:" msgstr "" "El código para ejecutar una función definida en un script de Python es:" #: ../Doc/extending/embedding.rst:146 msgid "" "This code loads a Python script using ``argv[1]``, and calls the function " "named in ``argv[2]``. Its integer arguments are the other values of the " "``argv`` array. If you :ref:`compile and link ` this program " "(let's call the finished executable :program:`call`), and use it to execute " "a Python script, such as:" msgstr "" "Este código carga un script de Python usando ``argv[1]`` y llama a la " "función nombrada en ``argv[2]``. Sus argumentos enteros son los otros " "valores del arreglo ``argv``. Si usted :ref:`compila y enlaza ` " "este programa (llamemos al ejecutable terminado :program:`call`), y úselo " "para ejecutar un script Python, como:" #: ../Doc/extending/embedding.rst:161 msgid "then the result should be:" msgstr "entonces el resultado debería ser:" #: ../Doc/extending/embedding.rst:169 msgid "" "Although the program is quite large for its functionality, most of the code " "is for data conversion between Python and C, and for error reporting. The " "interesting part with respect to embedding Python starts with ::" msgstr "" "Aunque el programa es bastante grande por su funcionalidad, la mayor parte " "del código es para la conversión de datos entre Python y C, y para informes " "de errores. La parte interesante con respecto a incrustar Python comienza " "con::" #: ../Doc/extending/embedding.rst:178 msgid "" "After initializing the interpreter, the script is loaded using :c:func:" "`PyImport_Import`. This routine needs a Python string as its argument, " "which is constructed using the :c:func:`PyUnicode_FromString` data " "conversion routine. ::" msgstr "" "Después de inicializar el intérprete, el script se carga usando :c:func:" "`PyImport_Import`. Esta rutina necesita una cadena Python como argumento, " "que se construye utilizando la rutina de conversión de datos :c:func:" "`PyUnicode_FromString`. ::" #: ../Doc/extending/embedding.rst:191 msgid "" "Once the script is loaded, the name we're looking for is retrieved using :c:" "func:`PyObject_GetAttrString`. If the name exists, and the object returned " "is callable, you can safely assume that it is a function. The program then " "proceeds by constructing a tuple of arguments as normal. The call to the " "Python function is then made with::" msgstr "" "Una vez que se carga el script, el nombre que estamos buscando se recupera " "usando :c:func:`PyObject_GetAttrString`. Si el nombre existe y el objeto " "retornado es invocable, puede asumir con seguridad que es una función. " "Luego, el programa continúa construyendo una tupla de argumentos como de " "costumbre. La llamada a la función Python se realiza con::" #: ../Doc/extending/embedding.rst:199 msgid "" "Upon return of the function, ``pValue`` is either ``NULL`` or it contains a " "reference to the return value of the function. Be sure to release the " "reference after examining the value." msgstr "" "Al regresar la función, ``pValue`` es ``NULL`` o contiene una referencia al " "valor de retorno de la función. Asegúrese de liberar la referencia después " "de examinar el valor." #: ../Doc/extending/embedding.rst:207 msgid "Extending Embedded Python" msgstr "Extendiendo Python Incrustado" #: ../Doc/extending/embedding.rst:209 msgid "" "Until now, the embedded Python interpreter had no access to functionality " "from the application itself. The Python API allows this by extending the " "embedded interpreter. That is, the embedded interpreter gets extended with " "routines provided by the application. While it sounds complex, it is not so " "bad. Simply forget for a while that the application starts the Python " "interpreter. Instead, consider the application to be a set of subroutines, " "and write some glue code that gives Python access to those routines, just " "like you would write a normal Python extension. For example::" msgstr "" "Hasta ahora, el intérprete de Python incorporado no tenía acceso a la " "funcionalidad de la aplicación misma. La API de Python lo permite al " "extender el intérprete incorporado. Es decir, el intérprete incorporado se " "amplía con las rutinas proporcionadas por la aplicación. Si bien suena " "complejo, no es tan malo. Simplemente olvide por un momento que la " "aplicación inicia el intérprete de Python. En cambio, considere que la " "aplicación es un conjunto de subrutinas y escriba un código de pegamento que " "le otorgue a Python acceso a esas rutinas, al igual que escribiría una " "extensión normal de Python. Por ejemplo::" #: ../Doc/extending/embedding.rst:246 msgid "" "Insert the above code just above the :c:func:`main` function. Also, insert " "the following two statements before the call to :c:func:`Py_Initialize`::" msgstr "" "Inserte el código anterior justo encima de la función :c:func:`main`. " "Además, inserte las siguientes dos declaraciones antes de la llamada a :c:" "func:`Py_Initialize`::" #: ../Doc/extending/embedding.rst:252 msgid "" "These two lines initialize the ``numargs`` variable, and make the :func:`emb." "numargs` function accessible to the embedded Python interpreter. With these " "extensions, the Python script can do things like" msgstr "" "Estas dos líneas inicializan la variable ``numargs`` y hacen que la función :" "func:`emb.numargs` sea accesible para el intérprete de Python incorporado. " "Con estas extensiones, el script de Python puede hacer cosas como" #: ../Doc/extending/embedding.rst:261 msgid "" "In a real application, the methods will expose an API of the application to " "Python." msgstr "" "En una aplicación real, los métodos expondrán una API de la aplicación a " "Python." #: ../Doc/extending/embedding.rst:271 msgid "Embedding Python in C++" msgstr "Incrustando Python en C++" #: ../Doc/extending/embedding.rst:273 msgid "" "It is also possible to embed Python in a C++ program; precisely how this is " "done will depend on the details of the C++ system used; in general you will " "need to write the main program in C++, and use the C++ compiler to compile " "and link your program. There is no need to recompile Python itself using C+" "+." msgstr "" "También es posible incrustar Python en un programa C++; precisamente cómo se " "hace esto dependerá de los detalles del sistema C++ utilizado; en general, " "necesitará escribir el programa principal en C++ y usar el compilador de C++ " "para compilar y vincular su programa. No es necesario volver a compilar " "Python usando C++." #: ../Doc/extending/embedding.rst:282 msgid "Compiling and Linking under Unix-like systems" msgstr "Compilar y enlazar bajo sistemas tipo Unix" #: ../Doc/extending/embedding.rst:284 msgid "" "It is not necessarily trivial to find the right flags to pass to your " "compiler (and linker) in order to embed the Python interpreter into your " "application, particularly because Python needs to load library modules " "implemented as C dynamic extensions (:file:`.so` files) linked against it." msgstr "" "No es necesariamente trivial encontrar los indicadores correctos para pasar " "a su compilador (y enlazador) para incrustar el intérprete de Python en su " "aplicación, particularmente porque Python necesita cargar módulos de " "biblioteca implementados como extensiones dinámicas en C (archivos :file:`." "so`) enlazados en su contra." #: ../Doc/extending/embedding.rst:290 msgid "" "To find out the required compiler and linker flags, you can execute the :" "file:`python{X.Y}-config` script which is generated as part of the " "installation process (a :file:`python3-config` script may also be " "available). This script has several options, of which the following will be " "directly useful to you:" msgstr "" "Para conocer los indicadores necesarios del compilador y el enlazador, puede " "ejecutar el script :file:`python{X.Y}-config` que se genera como parte del " "proceso de instalación (también puede estar disponible un script :file:" "`python3-config` ) Este script tiene varias opciones, de las cuales las " "siguientes serán directamente útiles para usted:" #: ../Doc/extending/embedding.rst:296 msgid "" "``pythonX.Y-config --cflags`` will give you the recommended flags when " "compiling:" msgstr "" "``pythonX.Y-config --cflags`` le dará las banderas recomendadas al compilar:" #: ../Doc/extending/embedding.rst:304 msgid "" "``pythonX.Y-config --ldflags`` will give you the recommended flags when " "linking:" msgstr "" "``pythonX.Y-config --ldflags`` le dará las banderas recomendadas al vincular:" #: ../Doc/extending/embedding.rst:313 msgid "" "To avoid confusion between several Python installations (and especially " "between the system Python and your own compiled Python), it is recommended " "that you use the absolute path to :file:`python{X.Y}-config`, as in the " "above example." msgstr "" "Para evitar confusiones entre varias instalaciones de Python (y " "especialmente entre el sistema Python y su propio Python compilado), se " "recomienda que use la ruta absoluta a :file:`python{X.Y}-config`, como en el " "ejemplo anterior." #: ../Doc/extending/embedding.rst:318 msgid "" "If this procedure doesn't work for you (it is not guaranteed to work for all " "Unix-like platforms; however, we welcome :ref:`bug reports `) you will have to read your system's documentation about dynamic " "linking and/or examine Python's :file:`Makefile` (use :func:`sysconfig." "get_makefile_filename` to find its location) and compilation options. In " "this case, the :mod:`sysconfig` module is a useful tool to programmatically " "extract the configuration values that you will want to combine together. " "For example:" msgstr "" "Si este procedimiento no funciona para usted (no se garantiza que funcione " "para todas las plataformas tipo Unix; sin embargo, le damos la bienvenida :" "ref:`informes de errores `) deberá leer la documentación de " "su sistema sobre dinámica vincular o examinar Python :file:`Makefile` (use :" "func:`sysconfig.get_makefile_filename` para encontrar su ubicación) y las " "opciones de compilación. En este caso, el módulo :mod:`sysconfig` es una " "herramienta útil para extraer mediante programación los valores de " "configuración que querrá combinar. Por ejemplo:"