-
-
Notifications
You must be signed in to change notification settings - Fork 405
Expand file tree
/
Copy path2.2.po
More file actions
2352 lines (2160 loc) · 120 KB
/
2.2.po
File metadata and controls
2352 lines (2160 loc) · 120 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# 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: 2022-10-25 19:47+0200\n"
"PO-Revision-Date: 2021-08-07 10:12+0100\n"
"Last-Translator: Claudia Millan <clmilneb@gmail.com>\n"
"Language: es\n"
"Language-Team: python-doc-es\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.10.3\n"
#: ../Doc/whatsnew/2.2.rst:3
msgid "What's New in Python 2.2"
msgstr "Qué hay de nuevo en Python 2.2"
#: ../Doc/whatsnew/2.2.rst
msgid "Author"
msgstr "Autor"
#: ../Doc/whatsnew/2.2.rst:5
msgid "A.M. Kuchling"
msgstr "A.M. Kuchling"
#: ../Doc/whatsnew/2.2.rst:13
msgid "Introduction"
msgstr "Introducción"
#: ../Doc/whatsnew/2.2.rst:15
msgid ""
"This article explains the new features in Python 2.2.2, released on October "
"14, 2002. Python 2.2.2 is a bugfix release of Python 2.2, originally "
"released on December 21, 2001."
msgstr ""
"Este artículo explica las nuevas características en Python 2.2.2, publicado "
"el 14 de octubre de 2002. Python 2.2.2 es una versión de corrección de "
"errores de Python 2.2, lanzada originalmente el 21 de diciembre de 2001."
#: ../Doc/whatsnew/2.2.rst:19
msgid ""
"Python 2.2 can be thought of as the \"cleanup release\". There are some "
"features such as generators and iterators that are completely new, but most "
"of the changes, significant and far-reaching though they may be, are aimed "
"at cleaning up irregularities and dark corners of the language design."
msgstr ""
"Python 2.2 se puede considerar como la \"versión de limpieza\". Hay algunas "
"características como los generadores e iteradores que son completamente "
"nuevas, pero la mayoría de los cambios, aunque sean significativos y de gran "
"alcance, tienen como objetivo limpiar las irregularidades y los rincones "
"oscuros del diseño del lenguaje."
#: ../Doc/whatsnew/2.2.rst:24
msgid ""
"This article doesn't attempt to provide a complete specification of the new "
"features, but instead provides a convenient overview. For full details, you "
"should refer to the documentation for Python 2.2, such as the `Python "
"Library Reference <https://docs.python.org/2.2/lib/lib.html>`_ and the "
"`Python Reference Manual <https://docs.python.org/2.2/ref/ref.html>`_. If "
"you want to understand the complete implementation and design rationale for "
"a change, refer to the PEP for a particular new feature."
msgstr ""
"Este artículo no procura proporcionar una especificación completa de las "
"nuevas características, pero en su lugar proporciona una descripción general "
"conveniente. Para más detalles, deberías consultar la documentación de "
"Python 2.2, como `Python Library Reference <https://docs.python.org/2.2/lib/"
"lib.html>`_ y `Python Reference Manual <https://docs.python.org/2.2/ref/ref."
"html>`_. Si quieres comprender la justificación completa de la "
"implementación y el diseño de un cambio, consultar la PEP para conocer una "
"característica nueva en particular."
#: ../Doc/whatsnew/2.2.rst:43
msgid "PEPs 252 and 253: Type and Class Changes"
msgstr "PEPs 252 y 253: Cambios de tipo y clase"
#: ../Doc/whatsnew/2.2.rst:45
msgid ""
"The largest and most far-reaching changes in Python 2.2 are to Python's "
"model of objects and classes. The changes should be backward compatible, so "
"it's likely that your code will continue to run unchanged, but the changes "
"provide some amazing new capabilities. Before beginning this, the longest "
"and most complicated section of this article, I'll provide an overview of "
"the changes and offer some comments."
msgstr ""
"Los cambios más grandes y de mayor alcance en Python 2.2 son el modelo de "
"objetos y clases de Python. Los cambios deben ser compatibles con versiones "
"anteriores, por lo que es probable que tu código continuará ejecutándose sin "
"cambios, pero los cambios proporcionan algunas capacidades nuevas "
"increíbles. Antes de comenzar esta, la sección más larga y complicada de "
"este artículo, brindaré una descripción general de los cambios y ofreceré "
"algunos comentarios."
#: ../Doc/whatsnew/2.2.rst:52
msgid ""
"A long time ago I wrote a web page listing flaws in Python's design. One of "
"the most significant flaws was that it's impossible to subclass Python types "
"implemented in C. In particular, it's not possible to subclass built-in "
"types, so you can't just subclass, say, lists in order to add a single "
"useful method to them. The :mod:`UserList` module provides a class that "
"supports all of the methods of lists and that can be subclassed further, but "
"there's lots of C code that expects a regular Python list and won't accept "
"a :class:`UserList` instance."
msgstr ""
"Hace mucho tiempo escribí una página web que enumeraba los defectos en el "
"diseño de Python. Una de las fallas más importantes fue que es imposible "
"subclasificar tipos de Python implementados en C. En particular, no es "
"posible subclasificar tipos incorporados, por lo que no se puede solo "
"subclasificar, digamos, listas para agregar un solo método útil para ellos. "
"El módulo :mod:`UserList` proporciona una clase que admite todos los métodos "
"de listas y que puede subclasificarse aún más, pero hay mucho código C que "
"espera una lista normal de Python y no aceptará una instancia :class:"
"`UserList`."
#: ../Doc/whatsnew/2.2.rst:61
msgid ""
"Python 2.2 fixes this, and in the process adds some exciting new "
"capabilities. A brief summary:"
msgstr ""
"Python 2.2 corrige esto y, en el proceso, agrega algunas capacidades nuevas "
"interesantes. Un breve resumen:"
#: ../Doc/whatsnew/2.2.rst:64
msgid ""
"You can subclass built-in types such as lists and even integers, and your "
"subclasses should work in every place that requires the original type."
msgstr ""
"Puedes subclasificar tipos incorporados como listas e incluso enteros, y tus "
"subclases deberían funcionar en todos los lugares que requieran el tipo "
"original."
#: ../Doc/whatsnew/2.2.rst:67
msgid ""
"It's now possible to define static and class methods, in addition to the "
"instance methods available in previous versions of Python."
msgstr ""
"Ahora es posible definir métodos estáticos y de clase, además de los métodos "
"de instancia disponibles en versiones anteriores de Python."
#: ../Doc/whatsnew/2.2.rst:70
msgid ""
"It's also possible to automatically call methods on accessing or setting an "
"instance attribute by using a new mechanism called :dfn:`properties`. Many "
"uses of :meth:`__getattr__` can be rewritten to use properties instead, "
"making the resulting code simpler and faster. As a small side benefit, "
"attributes can now have docstrings, too."
msgstr ""
"También es posible llamar automáticamente métodos al acceder o configurar un "
"atributo de instancia mediante el uso de un nuevo mecanismo llamado :dfn:"
"`properties`. Muchos usos de :meth:`__getattr__` se pueden reescribir para "
"usar propiedades en su lugar, haciendo que el código resultante sea más "
"simple y rápido. Como un pequeño beneficio secundario, ahora también los "
"atributos pueden tener docstrings."
#: ../Doc/whatsnew/2.2.rst:76
msgid ""
"The list of legal attributes for an instance can be limited to a particular "
"set using :dfn:`slots`, making it possible to safeguard against typos and "
"perhaps make more optimizations possible in future versions of Python."
msgstr ""
"La lista de atributos legales para una instancia se puede limitar a un "
"conjunto particular usando :dfn:`slots`, lo que hace posible protegerse "
"contra errores tipográficos y quizás hacer posibles más optimizaciones en "
"versiones futuras de Python."
#: ../Doc/whatsnew/2.2.rst:80
msgid ""
"Some users have voiced concern about all these changes. Sure, they say, the "
"new features are neat and lend themselves to all sorts of tricks that "
"weren't possible in previous versions of Python, but they also make the "
"language more complicated. Some people have said that they've always "
"recommended Python for its simplicity, and feel that its simplicity is being "
"lost."
msgstr ""
"Algunos usuarios han expresado preocupación por todos estos cambios. Claro, "
"dicen, las nuevas características son ordenadas y se prestan a todo tipo de "
"trucos que no eran posibles en versiones anteriores de Python, pero también "
"hacen que el lenguaje sea más complicado. Algunas personas han dicho que "
"siempre han recomendado Python por su simplicidad, y sienten que su "
"simplicidad se está perdiendo."
#: ../Doc/whatsnew/2.2.rst:86
msgid ""
"Personally, I think there's no need to worry. Many of the new features are "
"quite esoteric, and you can write a lot of Python code without ever needed "
"to be aware of them. Writing a simple class is no more difficult than it "
"ever was, so you don't need to bother learning or teaching them unless "
"they're actually needed. Some very complicated tasks that were previously "
"only possible from C will now be possible in pure Python, and to my mind "
"that's all for the better."
msgstr ""
"Personalmente. pienso que no hay que preocuparse. Muchas de las nuevas "
"características son bastante esotéricas, y puedes escribir mucho código de "
"Python sin tener que estar al tanto de ellas. Escribir una clase simple no "
"es más difícil de lo que nunca fue, así que no necesitas molestarte en "
"aprender o enseñarlos a menos que realmente sean necesarios. Algunas tareas "
"muy complicadas que antes solo eran posibles desde C ahora serán posibles en "
"Python puro, y en mi opinión, esto es todo para mejor."
#: ../Doc/whatsnew/2.2.rst:93
msgid ""
"I'm not going to attempt to cover every single corner case and small change "
"that were required to make the new features work. Instead this section will "
"paint only the broad strokes. See section :ref:`sect-rellinks`, \"Related "
"Links\", for further sources of information about Python 2.2's new object "
"model."
msgstr ""
"No voy a intentar cubrir todas los casos de las esquinas y los pequeños "
"cambios que fueron necesarios para hacer que las nuevas características "
"funcionen. En su lugar, esta sección pintará solo a grandes rasgos. "
"Consultar la sección :ref:`sect-rellinks`, \"Enlaces relacionados\", para "
"más fuentes de información sobre el nuevo modelo de objetos de Python 2.2."
#: ../Doc/whatsnew/2.2.rst:100
msgid "Old and New Classes"
msgstr "Clases antiguas y nuevas"
#: ../Doc/whatsnew/2.2.rst:102
msgid ""
"First, you should know that Python 2.2 really has two kinds of classes: "
"classic or old-style classes, and new-style classes. The old-style class "
"model is exactly the same as the class model in earlier versions of Python. "
"All the new features described in this section apply only to new-style "
"classes. This divergence isn't intended to last forever; eventually old-"
"style classes will be dropped, possibly in Python 3.0."
msgstr ""
"Primero, debes saber que realmente Python 2.2 tiene dos tipos de clases: "
"clases clásicas o de estilo antiguo y clases de estilo nuevo. El modelo de "
"clase de estilo antiguo exactamente es el mismo que el modelo de clase en "
"versiones anteriores de Python. Todas las nuevas características descritas "
"en esta sección se aplican solo a las clases de estilo nuevo. Esta "
"divergencia no está destinada a durar para siempre; eventualmente las clases "
"de estilo antiguo se eliminarán, posiblemente en Python 3.0."
#: ../Doc/whatsnew/2.2.rst:109
msgid ""
"So how do you define a new-style class? You do it by subclassing an "
"existing new-style class. Most of Python's built-in types, such as "
"integers, lists, dictionaries, and even files, are new-style classes now. A "
"new-style class named :class:`object`, the base class for all built-in "
"types, has also been added so if no built-in type is suitable, you can just "
"subclass :class:`object`::"
msgstr ""
"Entonces, ¿cómo defines una clase de estilo nuevo? Lo haces subclasificando "
"una clases de estilo nuevo existente. La mayoría de los tipos integrados de "
"Python, como enteros, listas, diccionarios e incluso archivos, ahora son "
"clases de estilo nuevo. También se agregó una clase de estilo nuevo llamada :"
"class:`object`, la clase base para todos los tipos integrados, por lo que si "
"ningún tipo integrado es apropiado, puedes solo subclasificar :class:"
"`object`::"
#: ../Doc/whatsnew/2.2.rst:121
msgid ""
"This means that :keyword:`class` statements that don't have any base classes "
"are always classic classes in Python 2.2. (Actually you can also change "
"this by setting a module-level variable named :attr:`__metaclass__` --- see :"
"pep:`253` for the details --- but it's easier to just subclass :class:"
"`object`.)"
msgstr ""
"Esto significa que las declaraciones :keyword:`class` que no tienen ninguna "
"clase base siempre son clases clásicas en Python 2.2. (Realmente también "
"puedes cambiar esto configurando una variable de nivel de módulo llamada :"
"attr:`__metaclass__` --- consultar :pep:`253` para más detalles --- pero es "
"más fácil solo subclasificar :class:`object`.)"
#: ../Doc/whatsnew/2.2.rst:126
msgid ""
"The type objects for the built-in types are available as built-ins, named "
"using a clever trick. Python has always had built-in functions named :func:"
"`int`, :func:`float`, and :func:`str`. In 2.2, they aren't functions any "
"more, but type objects that behave as factories when called. ::"
msgstr ""
"Los objetos de tipo para los tipos integrados están disponibles como "
"incorporados, nombrados mediante un truco inteligente. Python siempre ha "
"tenido funciones incorporadas llamadas :func:`int`, :func:`float` y :func:"
"`str`. En la versión 2.2, ya no son funciones, sino objetos de tipo que se "
"comportan como fábricas cuando se les llaman. ::"
#: ../Doc/whatsnew/2.2.rst:136
msgid ""
"To make the set of types complete, new type objects such as :func:`dict` "
"and :func:`file` have been added. Here's a more interesting example, adding "
"a :meth:`lock` method to file objects::"
msgstr ""
"Para completar el conjunto de tipos, se agregaron nuevos objetos de tipo "
"como :func:`dict` y :func:`file`. Aquí hay un ejemplo más interesante, "
"agregando un método :meth:`lock` a los objetos de archivo::"
#: ../Doc/whatsnew/2.2.rst:146
msgid ""
"The now-obsolete :mod:`posixfile` module contained a class that emulated all "
"of a file object's methods and also added a :meth:`lock` method, but this "
"class couldn't be passed to internal functions that expected a built-in "
"file, something which is possible with our new :class:`LockableFile`."
msgstr ""
"El módulo ahora obsoleto :mod:`posixfile` contenía una clase que emulaba "
"todos los métodos de un objeto de archivo y también agregaba un método :meth:"
"`lock`, pero esta clase no podía pasarse a funciones internas que esperaban "
"un archivo incorporado, algo que es posible con nuestra nueva clase :class:"
"`LockableFile`."
#: ../Doc/whatsnew/2.2.rst:153
msgid "Descriptors"
msgstr "Descriptores"
#: ../Doc/whatsnew/2.2.rst:155
msgid ""
"In previous versions of Python, there was no consistent way to discover what "
"attributes and methods were supported by an object. There were some informal "
"conventions, such as defining :attr:`__members__` and :attr:`__methods__` "
"attributes that were lists of names, but often the author of an extension "
"type or a class wouldn't bother to define them. You could fall back on "
"inspecting the :attr:`~object.__dict__` of an object, but when class "
"inheritance or an arbitrary :meth:`__getattr__` hook were in use this could "
"still be inaccurate."
msgstr ""
"En versiones anteriores de Python, no había una forma consistente de "
"descubrir qué atributos y métodos eran compatibles con un objeto. Había "
"algunas convenciones informales, como definir atributos :attr:`__members__` "
"y :attr:`__methods__` que eran listas de nombres, pero a menudo el autor de "
"un tipo de extensión o una clase no se molestaría en definirlos. Podrías "
"recurrir a inspeccionar el :attr:`~object.__dict__` de un objeto, pero "
"cuando la herencia de una clase o un gancho arbitrario :meth:`__getattr__` "
"estuvieran en uso, esto podría ser inexacto."
#: ../Doc/whatsnew/2.2.rst:163
msgid ""
"The one big idea underlying the new class model is that an API for "
"describing the attributes of an object using :dfn:`descriptors` has been "
"formalized. Descriptors specify the value of an attribute, stating whether "
"it's a method or a field. With the descriptor API, static methods and class "
"methods become possible, as well as more exotic constructs."
msgstr ""
"La única gran idea que subyace al nuevo modelo de clases es que se ha "
"formalizado una API para describir los atributos de un objeto usando :dfn:"
"`descriptors`. Los descriptores especifican el valor de un atributo, "
"indicando si es un método o un campo. Con la API de un descriptor, los "
"métodos estáticos y de clase se vuelven posibles, así como constructos más "
"exóticos."
#: ../Doc/whatsnew/2.2.rst:169
msgid ""
"Attribute descriptors are objects that live inside class objects, and have a "
"few attributes of their own:"
msgstr ""
"Los descriptores de atributos son objetos que viven dentro de los objetos de "
"clase y tienen algunos atributos propios:"
#: ../Doc/whatsnew/2.2.rst:172
msgid ":attr:`~definition.__name__` is the attribute's name."
msgstr ":attr:`~definition.__name__` es el nombre del atributo."
#: ../Doc/whatsnew/2.2.rst:174
msgid ":attr:`__doc__` is the attribute's docstring."
msgstr ":attr:`__doc__` es el docstring del atributo."
#: ../Doc/whatsnew/2.2.rst:176
msgid ""
"``__get__(object)`` is a method that retrieves the attribute value from "
"*object*."
msgstr ""
"``__get__(object)`` es un método que recupera el valor del atributo de "
"*object*."
#: ../Doc/whatsnew/2.2.rst:179
msgid "``__set__(object, value)`` sets the attribute on *object* to *value*."
msgstr ""
"``__set__(object, value)`` establece el atributo de *object* en *value*."
#: ../Doc/whatsnew/2.2.rst:181
msgid ""
"``__delete__(object, value)`` deletes the *value* attribute of *object*."
msgstr "``__delete__(object, value)`` elimina el atributo *value* de *object*."
#: ../Doc/whatsnew/2.2.rst:183
msgid ""
"For example, when you write ``obj.x``, the steps that Python actually "
"performs are::"
msgstr ""
"Por ejemplo, cuando escribes ``obj.x``, los pasos que realmente Python "
"realiza son::"
#: ../Doc/whatsnew/2.2.rst:189
msgid ""
"For methods, :meth:`descriptor.__get__` returns a temporary object that's "
"callable, and wraps up the instance and the method to be called on it. This "
"is also why static methods and class methods are now possible; they have "
"descriptors that wrap up just the method, or the method and the class. As a "
"brief explanation of these new kinds of methods, static methods aren't "
"passed the instance, and therefore resemble regular functions. Class "
"methods are passed the class of the object, but not the object itself. "
"Static and class methods are defined like this::"
msgstr ""
"Para los métodos, :meth:`descriptor.__get__` retorna un objeto temporal que "
"se puede llamar y contiene la instancia y el método que se llamará en él. "
"También esto es el por qué los métodos estáticos y de clase ahora son "
"posibles; tienen descriptores que contienen solo el método o el método y la "
"clase. Como una breve explicación de estos tipos nuevos de métodos, los "
"métodos estáticos no se pasan a la instancia y, por lo tanto, se asemejan a "
"funciones regulares. Los métodos de clase se pasan a la clase del objeto, "
"pero no al objeto en sí. Los métodos estáticos y de clase se definen así::"
#: ../Doc/whatsnew/2.2.rst:207
msgid ""
"The :func:`staticmethod` function takes the function :func:`f`, and returns "
"it wrapped up in a descriptor so it can be stored in the class object. You "
"might expect there to be special syntax for creating such methods (``def "
"static f``, ``defstatic f()``, or something like that) but no such syntax "
"has been defined yet; that's been left for future versions of Python."
msgstr ""
"La función :func:`staticmethod` toma la función :func:`f` y la retorna en un "
"descriptor para que pueda almacenarse en el objeto de clase. Puedes esperar "
"que haya una sintaxis especial para crear tales métodos (``def static f``, "
"``defstatic f()`` o algo así) pero aún no se ha definido dicha sintaxis; que "
"se ha dejado para versiones futuras de Python."
#: ../Doc/whatsnew/2.2.rst:213
msgid ""
"More new features, such as slots and properties, are also implemented as new "
"kinds of descriptors, and it's not difficult to write a descriptor class "
"that does something novel. For example, it would be possible to write a "
"descriptor class that made it possible to write Eiffel-style preconditions "
"and postconditions for a method. A class that used this feature might be "
"defined like this::"
msgstr ""
"También se implementan más características nuevas, como ranuras y "
"propiedades, como nuevos tipos de descriptores, y no es difícil escribir una "
"clase de descriptor que haga algo nuevo. Por ejemplo, sería posible escribir "
"una clase de descriptor que hiciera posible escribir condiciones previas al "
"estilo Eiffel y posteriores para un método. Una clase que usó esta "
"característica podría definirse así::"
#: ../Doc/whatsnew/2.2.rst:235
msgid ""
"Note that a person using the new :func:`eiffelmethod` doesn't have to "
"understand anything about descriptors. This is why I think the new features "
"don't increase the basic complexity of the language. There will be a few "
"wizards who need to know about it in order to write :func:`eiffelmethod` or "
"the ZODB or whatever, but most users will just write code on top of the "
"resulting libraries and ignore the implementation details."
msgstr ""
"Toma en cuenta que una persona que usa la nueva función :func:`eiffelmethod` "
"no tiene que entender nada sobre descriptores. Esta es la razón por la que "
"creo que las nuevas características no incrementan la complejidad básica del "
"lenguaje. Habrá algunos asistentes que necesitarán conocerlo para escribir :"
"func:`eiffelmethod` o la ZODB o lo que sea, pero la mayoría de los usuarios "
"solo escribirán código sobre las bibliotecas resultantes e ignorarán los "
"detalles de implementación."
#: ../Doc/whatsnew/2.2.rst:244
msgid "Multiple Inheritance: The Diamond Rule"
msgstr "Herencia múltiple: la regla del diamante"
#: ../Doc/whatsnew/2.2.rst:246
msgid ""
"Multiple inheritance has also been made more useful through changing the "
"rules under which names are resolved. Consider this set of classes (diagram "
"taken from :pep:`253` by Guido van Rossum)::"
msgstr ""
"La herencia múltiple también se ha hecho más útil al cambiar las reglas bajo "
"las cuales se resuelven los nombres. Considera este conjunto de clases "
"(diagrama tomado de :pep:`253` de Guido van Rossum)::"
#: ../Doc/whatsnew/2.2.rst:264
msgid ""
"The lookup rule for classic classes is simple but not very smart; the base "
"classes are searched depth-first, going from left to right. A reference to :"
"meth:`D.save` will search the classes :class:`D`, :class:`B`, and then :"
"class:`A`, where :meth:`save` would be found and returned. :meth:`C.save` "
"would never be found at all. This is bad, because if :class:`C`'s :meth:"
"`save` method is saving some internal state specific to :class:`C`, not "
"calling it will result in that state never getting saved."
msgstr ""
"La regla de búsqueda para clases clásicas es simple pero no muy inteligente; "
"se buscan las clases base primero en profundidad, yendo de izquierda a "
"derecha. Una referencia a :meth:`D.save` buscará las clases :class:`D`, :"
"class:`B` y luego :class:`A`, donde :meth:`save` se encontraría y "
"retornaría. :meth:`C.save` nunca se encontraría en absoluto. Esto es malo, "
"porque si el método :meth:`save` de :class:`C` está guardando algún estado "
"interno específico de :class:`C`, no llamarlo resultará en que este estado "
"nunca se guardará."
#: ../Doc/whatsnew/2.2.rst:272
msgid ""
"New-style classes follow a different algorithm that's a bit more complicated "
"to explain, but does the right thing in this situation. (Note that Python "
"2.3 changes this algorithm to one that produces the same results in most "
"cases, but produces more useful results for really complicated inheritance "
"graphs.)"
msgstr ""
"Las clases de estilo nuevo siguen un algoritmo diferente que es más "
"complicado de explicar, pero hace lo correcto en esta situación. (Toma en "
"cuenta que Python 2.3 cambia este algoritmo a uno que produce los mismos "
"resultados en la mayoría de los casos, pero produce resultados más útiles "
"para gráficos de herencia realmente complicados.)"
#: ../Doc/whatsnew/2.2.rst:277
msgid ""
"List all the base classes, following the classic lookup rule and include a "
"class multiple times if it's visited repeatedly. In the above example, the "
"list of visited classes is [:class:`D`, :class:`B`, :class:`A`, :class:`C`, :"
"class:`A`]."
msgstr ""
"Enumera todas las clases base, siguiendo la regla de búsqueda clásica e "
"incluye una clase varias veces si se visita repetidamente. En el ejemplo "
"anterior, la lista de clases visitadas es [:class:`D`, :class:`B`, :class:"
"`A`, :class:`C`, :class:`A`]."
#: ../Doc/whatsnew/2.2.rst:282
msgid ""
"Scan the list for duplicated classes. If any are found, remove all but one "
"occurrence, leaving the *last* one in the list. In the above example, the "
"list becomes [:class:`D`, :class:`B`, :class:`C`, :class:`A`] after dropping "
"duplicates."
msgstr ""
"Escanea la lista en busca de clases duplicadas. Si encuentra alguna, elimina "
"todas menos una, dejando la *última* en la lista. En el ejemplo anterior, la "
"lista se convierte en [:class:`D`, :class:`B`, :class:`C`, :class:`A`] "
"después de eliminar las duplicadas."
#: ../Doc/whatsnew/2.2.rst:287
msgid ""
"Following this rule, referring to :meth:`D.save` will return :meth:`C.save`, "
"which is the behaviour we're after. This lookup rule is the same as the one "
"followed by Common Lisp. A new built-in function, :func:`super`, provides a "
"way to get at a class's superclasses without having to reimplement Python's "
"algorithm. The most commonly used form will be ``super(class, obj)``, which "
"returns a bound superclass object (not the actual class object). This form "
"will be used in methods to call a method in the superclass; for example, :"
"class:`D`'s :meth:`save` method would look like this::"
msgstr ""
"Siguiendo esta regla, refiriéndose a :meth:`D.save` retornará :meth:`C."
"save`, el cual es el comportamiento que buscamos. Esta regla de búsqueda es "
"la misma que sigue Common Lisp. Una nueva función incorporada, :func:"
"`super`, proporciona una forma de acceder a las superclases de una clase sin "
"tener que volver a implementar el algoritmo de Python. La forma más "
"utilizada será ``super(class, obj)``, la cual retorna un objeto de "
"superclase vinculado. Esta forma se usará en métodos para llamar a un método "
"en la superclase; por ejemplo, el método :meth:`save` de :class:`D` se vería "
"así::"
#: ../Doc/whatsnew/2.2.rst:303
msgid ""
":func:`super` can also return unbound superclass objects when called as "
"``super(class)`` or ``super(class1, class2)``, but this probably won't often "
"be useful."
msgstr ""
"También :func:`super` puede retornar objetos de superclase no vinculados "
"cuando se llama como ``super(class)`` o ``super(class1, class2)``, pero "
"probablemente esto no sea útil a menudo."
#: ../Doc/whatsnew/2.2.rst:309
msgid "Attribute Access"
msgstr "Acceso a atributos"
#: ../Doc/whatsnew/2.2.rst:311
msgid ""
"A fair number of sophisticated Python classes define hooks for attribute "
"access using :meth:`__getattr__`; most commonly this is done for "
"convenience, to make code more readable by automatically mapping an "
"attribute access such as ``obj.parent`` into a method call such as ``obj."
"get_parent``. Python 2.2 adds some new ways of controlling attribute access."
msgstr ""
"Un buen número de clases sofisticadas de Python definen ganchos para el "
"acceso de atributos usando :meth:`__getattr__`; más comúnmente, esto se hace "
"por conveniencia, para hacer que el código sea más legible al mapear "
"automáticamente un acceso de atributo como ``obj.parent`` en una llamada de "
"método como ``obj.get_parent``. Python 2.2 agrega algunas formas nuevas de "
"controlar el acceso de atributos."
#: ../Doc/whatsnew/2.2.rst:317
msgid ""
"First, ``__getattr__(attr_name)`` is still supported by new-style classes, "
"and nothing about it has changed. As before, it will be called when an "
"attempt is made to access ``obj.foo`` and no attribute named ``foo`` is "
"found in the instance's dictionary."
msgstr ""
"Primero, ``__getattr__(attr_name)`` aún es compatible con las clases de "
"nuevo estilo, y nada al respecto ha cambiado. Como antes, se llamará cuando "
"se intente acceder a ``obj.foo`` y no se encuentre ningún atributo llamado "
"``foo`` en el diccionario de la instancia."
#: ../Doc/whatsnew/2.2.rst:322
msgid ""
"New-style classes also support a new method, "
"``__getattribute__(attr_name)``. The difference between the two methods is "
"that :meth:`__getattribute__` is *always* called whenever any attribute is "
"accessed, while the old :meth:`__getattr__` is only called if ``foo`` isn't "
"found in the instance's dictionary."
msgstr ""
"Las clases de nuevo estilo también admiten un nuevo método, "
"``__getattribute__(attr_name)``. La diferencia entre los dos métodos es que :"
"meth:`__getattribute__` *siempre* se llama cada vez que se accede a "
"cualquier atributo, mientras que el antiguo :meth:`__getattr__` se llama "
"solo si no se encuentra ``foo`` en el diccionario de la instancia."
#: ../Doc/whatsnew/2.2.rst:328
msgid ""
"However, Python 2.2's support for :dfn:`properties` will often be a simpler "
"way to trap attribute references. Writing a :meth:`__getattr__` method is "
"complicated because to avoid recursion you can't use regular attribute "
"accesses inside them, and instead have to mess around with the contents of :"
"attr:`~object.__dict__`. :meth:`__getattr__` methods also end up being "
"called by Python when it checks for other methods such as :meth:`__repr__` "
"or :meth:`__coerce__`, and so have to be written with this in mind. Finally, "
"calling a function on every attribute access results in a sizable "
"performance loss."
msgstr ""
"Sin embargo, el soporte de Python 2.2 para :dfn:`properties` será a menudo "
"una forma más simple de atrapar referencias de atributos. Escribir un "
"método :meth:`__getattr__` es complicado porque para evitar la recursividad "
"no puedes usar accesos regulares a atributos dentro de ellos, y en su lugar "
"tienes que jugar con el contenido de :attr:`~object.__dict__`. Los métodos :"
"meth:`__getattr__` también terminan siendo llamados por Python cuando busca "
"otros métodos como :meth:`__repr__` o :meth:`__coerce__`, por lo que se "
"tienen que escribirse teniendo esto en cuenta. Finalmente, llamar una "
"función en cada acceso de atributo resulta en una pérdida de rendimiento "
"considerable."
#: ../Doc/whatsnew/2.2.rst:337
msgid ""
":class:`property` is a new built-in type that packages up three functions "
"that get, set, or delete an attribute, and a docstring. For example, if you "
"want to define a :attr:`size` attribute that's computed, but also settable, "
"you could write::"
msgstr ""
":class:`property` es un nuevo tipo integrado que empaqueta tres funciones "
"obtienen, establecen o eliminan un atributo y una docstring. Por ejemplo, si "
"quieres definir un atributo :attr:`size` que se calcula, pero que también se "
"puede configurar, puedes escribir::"
#: ../Doc/whatsnew/2.2.rst:357
msgid ""
"That is certainly clearer and easier to write than a pair of :meth:"
"`__getattr__`/:meth:`__setattr__` methods that check for the :attr:`size` "
"attribute and handle it specially while retrieving all other attributes from "
"the instance's :attr:`~object.__dict__`. Accesses to :attr:`size` are also "
"the only ones which have to perform the work of calling a function, so "
"references to other attributes run at their usual speed."
msgstr ""
"Eso es ciertamente más claro y fácil de escribir que un par de métodos :meth:"
"`__getattr__`/:meth:`__setattr__` que verifican el atributo :attr:`size` y "
"lo manejan especialmente mientras recuperan todos los demás atributos :attr:"
"`~object.__dict__` de la instancia. Los accesos a :attr:`size` también son "
"los únicos que tienen que realizar el trabajo de llamar a una función, por "
"lo que las referencias a otros atributos se ejecutan a su velocidad habitual."
#: ../Doc/whatsnew/2.2.rst:364
msgid ""
"Finally, it's possible to constrain the list of attributes that can be "
"referenced on an object using the new :attr:`~object.__slots__` class "
"attribute. Python objects are usually very dynamic; at any time it's "
"possible to define a new attribute on an instance by just doing ``obj."
"new_attr=1``. A new-style class can define a class attribute named :attr:"
"`~object.__slots__` to limit the legal attributes to a particular set of "
"names. An example will make this clear::"
msgstr ""
"Finalmente, es posible restringir la lista de atributos que se pueden "
"referenciar en un objeto usando el nuevo atributo de clase :attr:`~object."
"__slots__`. Los objetos de Python por lo general son muy dinámicos; en "
"cualquier momento es posible definir un nuevo atributo en una instancia "
"haciendo simplemente ``obj.new_attr=1``. Una clase de estilo nuevo puede "
"definir un atributo de clase llamado :attr:`~object.__slots__` para limitar "
"los atributos legales a un conjunto particular de nombres. Un ejemplo hará "
"esto claro::"
#: ../Doc/whatsnew/2.2.rst:385
msgid ""
"Note how you get an :exc:`AttributeError` on the attempt to assign to an "
"attribute not listed in :attr:`~object.__slots__`."
msgstr ""
"Toma en cuenta cómo obtienes un :exc:`AttributeError` en el intento de "
"asignar a un atributo que no aparece en :attr:`~object.__slots__`."
#: ../Doc/whatsnew/2.2.rst:392
msgid "Related Links"
msgstr "Enlaces relacionados"
#: ../Doc/whatsnew/2.2.rst:394
msgid ""
"This section has just been a quick overview of the new features, giving "
"enough of an explanation to start you programming, but many details have "
"been simplified or ignored. Where should you go to get a more complete "
"picture?"
msgstr ""
"Esta sección solo ha sido una descripción rápida de las nuevas "
"características, brindando una explicación suficiente para comenzar a "
"programar, pero muchos detalles se han simplificado o ignorado. ¿Dónde "
"deberías ir para obtener una imagen más completa?"
#: ../Doc/whatsnew/2.2.rst:398
msgid ""
"https://docs.python.org/dev/howto/descriptor.html is a lengthy tutorial "
"introduction to the descriptor features, written by Guido van Rossum. If my "
"description has whetted your appetite, go read this tutorial next, because "
"it goes into much more detail about the new features while still remaining "
"quite easy to read."
msgstr ""
"https://docs.python.org/dev/howto/descriptor.html es un extenso tutorial de "
"introducción a las características del descriptor, escrito por Guido van "
"Rossum. Si mi descripción te despertó el apetito, lee este tutorial a "
"continuación, porque entra en mucho más detalle sobre las nuevas "
"características sin dejar de ser bastante fácil de leer."
#: ../Doc/whatsnew/2.2.rst:403
msgid ""
"Next, there are two relevant PEPs, :pep:`252` and :pep:`253`. :pep:`252` is "
"titled \"Making Types Look More Like Classes\", and covers the descriptor "
"API. :pep:`253` is titled \"Subtyping Built-in Types\", and describes the "
"changes to type objects that make it possible to subtype built-in objects. :"
"pep:`253` is the more complicated PEP of the two, and at a few points the "
"necessary explanations of types and meta-types may cause your head to "
"explode. Both PEPs were written and implemented by Guido van Rossum, with "
"substantial assistance from the rest of the Zope Corp. team."
msgstr ""
"A continuación, hay dos PEPs relevantes, :pep:`252` y :pep:`253`. :pep:`252` "
"se titula \"Hacer que los tipos se parezcan más a las clases\", y cubre la "
"API del descriptor. :pep:`253` se titula \"Subtipado de tipos "
"incorporados\", y describe los cambios de los objetos de tipo que hacen "
"posible el subtipo de objetos incorporados. :pep:`253` es la PEP más "
"complicada de las dos, y en algunos puntos las explicaciones necesarias de "
"tipos y meta-tipos pueden causar que tu cabeza explote. Ambas PEPs se "
"escribieron e implementaron por Guido van Rossum con la asistencia "
"sustancial del resto del equipo de Zope Corp."
#: ../Doc/whatsnew/2.2.rst:412
msgid ""
"Finally, there's the ultimate authority: the source code. Most of the "
"machinery for the type handling is in :file:`Objects/typeobject.c`, but you "
"should only resort to it after all other avenues have been exhausted, "
"including posting a question to python-list or python-dev."
msgstr ""
"Finalmente, está la máxima autoridad: el código fuente. La mayoría de la "
"maquinaria para el manejo de tipos está en :file:`Objects/typeobject.c`, "
"pero solo debes recurrir a él después de que se hayan agotado todas las "
"demás vías, incluida la publicación de una pregunta en python-list o python-"
"dev."
#: ../Doc/whatsnew/2.2.rst:421
msgid "PEP 234: Iterators"
msgstr "PEP 234: Iteradores"
#: ../Doc/whatsnew/2.2.rst:423
msgid ""
"Another significant addition to 2.2 is an iteration interface at both the C "
"and Python levels. Objects can define how they can be looped over by "
"callers."
msgstr ""
"Otra adición significativa a la versión 2.2 es una interfaz de iteración "
"tanto a nivel de C como de Python. Los objetos pueden definir cómo pueden "
"ser iterados por quienes los llaman."
#: ../Doc/whatsnew/2.2.rst:426
msgid ""
"In Python versions up to 2.1, the usual way to make ``for item in obj`` work "
"is to define a :meth:`__getitem__` method that looks something like this::"
msgstr ""
"En las versiones de Python hasta la 2.1, la forma habitual de hacer que "
"funcione ``for item in obj`` es definir un método :meth:`__getitem__` que se "
"parezca a esto::"
#: ../Doc/whatsnew/2.2.rst:432
msgid ""
":meth:`__getitem__` is more properly used to define an indexing operation on "
"an object so that you can write ``obj[5]`` to retrieve the sixth element. "
"It's a bit misleading when you're using this only to support :keyword:`for` "
"loops. Consider some file-like object that wants to be looped over; the "
"*index* parameter is essentially meaningless, as the class probably assumes "
"that a series of :meth:`__getitem__` calls will be made with *index* "
"incrementing by one each time. In other words, the presence of the :meth:"
"`__getitem__` method doesn't mean that using ``file[5]`` to randomly access "
"the sixth element will work, though it really should."
msgstr ""
":meth:`__getitem__` se utiliza más adecuadamente para definir una operación "
"de indexación en un objeto, de modo que se puede escribir ``obj[5]`` para "
"recuperar el sexto elemento. Es un poco engañoso cuando se utiliza esto "
"sólo para soportar bucles :keyword:`for`. Considere algún objeto tipo "
"archivo que quiera ser revisado en bucle; el parámetro *index* no tiene "
"sentido, ya que la clase probablemente asume que se hará una serie de "
"llamadas a :meth:`__getitem__` con *index* incrementándose en uno cada vez. "
"En otras palabras, la presencia del método :meth:`__getitem__` no significa "
"que el uso de ``file[5]`` para acceder al azar al sexto elemento vaya a "
"funcionar, aunque realmente debería hacerlo."
#: ../Doc/whatsnew/2.2.rst:442
msgid ""
"In Python 2.2, iteration can be implemented separately, and :meth:"
"`__getitem__` methods can be limited to classes that really do support "
"random access. The basic idea of iterators is simple. A new built-in "
"function, ``iter(obj)`` or ``iter(C, sentinel)``, is used to get an "
"iterator. ``iter(obj)`` returns an iterator for the object *obj*, while "
"``iter(C, sentinel)`` returns an iterator that will invoke the callable "
"object *C* until it returns *sentinel* to signal that the iterator is done."
msgstr ""
"En Python 2.2, la iteración puede implementarse por separado, y los métodos :"
"meth:`__getitem__` pueden limitarse a las clases que realmente soportan el "
"acceso aleatorio. La idea básica de los iteradores es simple. Una nueva "
"función incorporada, ``iter(obj)`` o ``iter(C, sentinel)``, se utiliza para "
"obtener un iterador. ``iter(obj)`` retorna un iterador para el objeto *obj*, "
"mientras que ``iter(C, sentinel)`` retorna un iterador que invocará al "
"objeto invocable *C* hasta que retorne *sentinel* para señalar que el "
"iterador ha terminado."
#: ../Doc/whatsnew/2.2.rst:450
msgid ""
"Python classes can define an :meth:`__iter__` method, which should create "
"and return a new iterator for the object; if the object is its own iterator, "
"this method can just return ``self``. In particular, iterators will usually "
"be their own iterators. Extension types implemented in C can implement a :c:"
"member:`~PyTypeObject.tp_iter` function in order to return an iterator, and "
"extension types that want to behave as iterators can define a :c:member:"
"`~PyTypeObject.tp_iternext` function."
msgstr ""
"Las clases de Python pueden definir un método :meth:`__iter__`, que debe "
"crear y retornar un nuevo iterador para el objeto; si el objeto es su propio "
"iterador, este método puede simplemente retornar ``self``. En particular, "
"los iteradores suelen ser sus propios iteradores. Los tipos de extensión "
"implementados en C pueden implementar una función :c:member:`~PyTypeObject."
"tp_iter` para retornar un iterador, y los tipos de extensión que quieran "
"comportarse como iteradores pueden definir una función :c:member:"
"`~PyTypeObject.tp_iternext`."
#: ../Doc/whatsnew/2.2.rst:457
msgid ""
"So, after all this, what do iterators actually do? They have one required "
"method, :meth:`next`, which takes no arguments and returns the next value. "
"When there are no more values to be returned, calling :meth:`next` should "
"raise the :exc:`StopIteration` exception. ::"
msgstr ""
"Entonces, después de todo esto, ¿qué hacen realmente los iteradores? Tienen "
"un método obligatorio, :meth:`next`, que no toma argumentos y retorna el "
"siguiente valor. Cuando no hay más valores que retornar, la llamada a :meth:"
"`next` debería lanzar la excepción :exc:`StopIteration`. ::"
#: ../Doc/whatsnew/2.2.rst:478
msgid ""
"In 2.2, Python's :keyword:`for` statement no longer expects a sequence; it "
"expects something for which :func:`iter` will return an iterator. For "
"backward compatibility and convenience, an iterator is automatically "
"constructed for sequences that don't implement :meth:`__iter__` or a :c:"
"member:`~PyTypeObject.tp_iter` slot, so ``for i in [1,2,3]`` will still "
"work. Wherever the Python interpreter loops over a sequence, it's been "
"changed to use the iterator protocol. This means you can do things like "
"this::"
msgstr ""
"En 2.2, la sentencia :keyword:`for` de Python ya no espera una secuencia; "
"espera algo para lo que :func:`iter` retornará un iterador. Por "
"compatibilidad y comodidad, se construye automáticamente un iterador para "
"las secuencias que no implementan :meth:`__iter__` o una ranura :c:member:"
"`~PyTypeObject.tp_iter`, por lo que ``for i in [1,2,3]`` seguirá "
"funcionando. Dondequiera que el intérprete de Python haga un bucle sobre "
"una secuencia, se ha cambiado para utilizar el protocolo de los iteradores. "
"Esto significa que puedes hacer cosas como esta::"
#: ../Doc/whatsnew/2.2.rst:492
msgid ""
"Iterator support has been added to some of Python's basic types. Calling :"
"func:`iter` on a dictionary will return an iterator which loops over its "
"keys::"
msgstr ""
"Se ha añadido soporte de iteradores a algunos de los tipos básicos de "
"Python. Llamar a :func:`iter` sobre un diccionario retornará un iterador "
"que hace un bucle sobre sus claves::"
#: ../Doc/whatsnew/2.2.rst:512
msgid ""
"That's just the default behaviour. If you want to iterate over keys, "
"values, or key/value pairs, you can explicitly call the :meth:`iterkeys`, :"
"meth:`itervalues`, or :meth:`iteritems` methods to get an appropriate "
"iterator. In a minor related change, the :keyword:`in` operator now works on "
"dictionaries, so ``key in dict`` is now equivalent to ``dict.has_key(key)``."
msgstr ""
"Este es el comportamiento por defecto. Si quieres iterar sobre claves, "
"valores o pares clave/valor, puedes llamar explícitamente a los métodos :"
"meth:`iterkeys`, :meth:`itervalues` o :meth:`iteritems` para obtener un "
"iterador apropiado. En un cambio menor relacionado, el operador :keyword:"
"`in` ahora funciona en los diccionarios, por lo que ``key in dict`` es ahora "
"equivalente a ``dict.has_key(key)``."
#: ../Doc/whatsnew/2.2.rst:518
msgid ""
"Files also provide an iterator, which calls the :meth:`readline` method "
"until there are no more lines in the file. This means you can now read each "
"line of a file using code like this::"
msgstr ""
"Los archivos también proporcionan un iterador, que llama al método :meth:"
"`readline` hasta que no hay más líneas en el archivo. Esto significa que "
"ahora puede leer cada línea de un archivo utilizando un código como este::"
#: ../Doc/whatsnew/2.2.rst:526
msgid ""
"Note that you can only go forward in an iterator; there's no way to get the "
"previous element, reset the iterator, or make a copy of it. An iterator "
"object could provide such additional capabilities, but the iterator protocol "
"only requires a :meth:`next` method."
msgstr ""
"Tenga en cuenta que sólo puede avanzar en un iterador; no hay forma de "
"obtener el elemento anterior, reiniciar el iterador o hacer una copia del "
"mismo. Un objeto iterador podría proporcionar estas capacidades adicionales, "
"pero el protocolo iterador sólo requiere un método :meth:`next`."
#: ../Doc/whatsnew/2.2.rst:535
msgid ":pep:`234` - Iterators"
msgstr ":pep:`234` - Iteradores"
#: ../Doc/whatsnew/2.2.rst:535
msgid ""
"Written by Ka-Ping Yee and GvR; implemented by the Python Labs crew, mostly "
"by GvR and Tim Peters."
msgstr ""
"Escrito por Ka-Ping Yee y GvR; implementado por el equipo de Python Labs, "
"principalmente por GvR y Tim Peters."
#: ../Doc/whatsnew/2.2.rst:542
msgid "PEP 255: Simple Generators"
msgstr "PEP 255: Generadores simples"
#: ../Doc/whatsnew/2.2.rst:544
msgid ""
"Generators are another new feature, one that interacts with the introduction "
"of iterators."
msgstr ""
"Los generadores son otra novedad que interactúa con la introducción de los "
"iteradores."
#: ../Doc/whatsnew/2.2.rst:547
msgid ""
"You're doubtless familiar with how function calls work in Python or C. When "
"you call a function, it gets a private namespace where its local variables "
"are created. When the function reaches a :keyword:`return` statement, the "
"local variables are destroyed and the resulting value is returned to the "
"caller. A later call to the same function will get a fresh new set of local "
"variables. But, what if the local variables weren't thrown away on exiting a "
"function? What if you could later resume the function where it left off? "
"This is what generators provide; they can be thought of as resumable "
"functions."
msgstr ""
"Sin duda estás familiarizado con cómo funcionan las llamadas a funciones en "
"Python o C. Cuando llamas a una función, ésta obtiene un espacio de nombres "
"privado donde se crean sus variables locales. Cuando la función llega a una "
"declaración :keyword:`return`, las variables locales se destruyen y el valor "
"resultante se retorna a quien la llamó. Una llamada posterior a la misma "
"función obtendrá un nuevo conjunto de variables locales. Pero, ¿qué pasaría "
"si las variables locales no se tiraran al salir de una función? ¿Qué pasaría "
"si pudieras reanudar la función donde la dejaste? Esto es lo que "
"proporcionan los generadores; se puede pensar en ellos como funciones "
"reanudables."
#: ../Doc/whatsnew/2.2.rst:556
msgid "Here's the simplest example of a generator function::"
msgstr "Este es el ejemplo más sencillo de una función generadora::"
#: ../Doc/whatsnew/2.2.rst:562
msgid ""
"A new keyword, :keyword:`yield`, was introduced for generators. Any "
"function containing a :keyword:`!yield` statement is a generator function; "
"this is detected by Python's bytecode compiler which compiles the function "
"specially as a result. Because a new keyword was introduced, generators "
"must be explicitly enabled in a module by including a ``from __future__ "
"import generators`` statement near the top of the module's source code. In "
"Python 2.3 this statement will become unnecessary."
msgstr ""
"Se ha introducido una nueva palabra clave, :keyword:`yield`, para los "
"generadores. Cualquier función que contenga una declaración :keyword:`!"
"yield` es una función generadora; esto es detectado por el compilador de "
"código de bits de Python que compila la función especialmente como "
"resultado. Debido a la introducción de una nueva palabra clave, los "
"generadores deben ser explícitamente habilitados en un módulo incluyendo una "
"declaración ``from __future__ import generators`` cerca de la parte superior "
"del código fuente del módulo. En Python 2.3 esta declaración será "
"innecesaria."
#: ../Doc/whatsnew/2.2.rst:570
msgid ""
"When you call a generator function, it doesn't return a single value; "
"instead it returns a generator object that supports the iterator protocol. "
"On executing the :keyword:`yield` statement, the generator outputs the value "
"of ``i``, similar to a :keyword:`return` statement. The big difference "
"between :keyword:`!yield` and a :keyword:`!return` statement is that on "
"reaching a :keyword:`!yield` the generator's state of execution is suspended "
"and local variables are preserved. On the next call to the generator's "
"``next()`` method, the function will resume executing immediately after the :"
"keyword:`!yield` statement. (For complicated reasons, the :keyword:`!yield` "
"statement isn't allowed inside the :keyword:`!try` block of a :keyword:"
"`try`...\\ :keyword:`finally` statement; read :pep:`255` for a full "
"explanation of the interaction between :keyword:`!yield` and exceptions.)"
msgstr ""
"Cuando se llama a una función generadora, ésta no retorna un único valor, "
"sino que retorna un objeto generador que soporta el protocolo de los "
"iteradores. Al ejecutar la sentencia :keyword:`yield`, el generador retorna "
"el valor de ``i``, de forma similar a una sentencia :keyword:`return`. La "