forked from python/python-docs-es
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdescriptor.po
More file actions
1363 lines (1174 loc) · 50.1 KB
/
descriptor.po
File metadata and controls
1363 lines (1174 loc) · 50.1 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: 2021-03-19 11:16+0100\n"
"PO-Revision-Date: 2020-08-20 15:05+0200\n"
"Last-Translator: Francisco Jesús Sevilla García <fjsevilla.dev@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.8.0\n"
#: ../Doc/howto/descriptor.rst:5
msgid "Descriptor HowTo Guide"
msgstr "Guía práctica de uso de los descriptores"
#: ../Doc/howto/descriptor.rst
msgid "Author"
msgstr "Autor"
#: ../Doc/howto/descriptor.rst:7
msgid "Raymond Hettinger"
msgstr "Raymond Hettinger"
#: ../Doc/howto/descriptor.rst
msgid "Contact"
msgstr "Contacto"
#: ../Doc/howto/descriptor.rst:8
msgid "<python at rcn dot com>"
msgstr "<python at rcn dot com>"
#: ../Doc/howto/descriptor.rst:11
msgid "Contents"
msgstr "Contenidos"
#: ../Doc/howto/descriptor.rst:13
msgid ""
":term:`Descriptors <descriptor>` let objects customize attribute lookup, "
"storage, and deletion."
msgstr ""
#: ../Doc/howto/descriptor.rst:16
msgid "This guide has four major sections:"
msgstr ""
#: ../Doc/howto/descriptor.rst:18
msgid ""
"The \"primer\" gives a basic overview, moving gently from simple examples, "
"adding one feature at a time. Start here if you're new to descriptors."
msgstr ""
#: ../Doc/howto/descriptor.rst:21
msgid ""
"The second section shows a complete, practical descriptor example. If you "
"already know the basics, start there."
msgstr ""
#: ../Doc/howto/descriptor.rst:24
msgid ""
"The third section provides a more technical tutorial that goes into the "
"detailed mechanics of how descriptors work. Most people don't need this "
"level of detail."
msgstr ""
#: ../Doc/howto/descriptor.rst:28
msgid ""
"The last section has pure Python equivalents for built-in descriptors that "
"are written in C. Read this if you're curious about how functions turn into "
"bound methods or about the implementation of common tools like :func:"
"`classmethod`, :func:`staticmethod`, :func:`property`, and :term:`__slots__`."
msgstr ""
#: ../Doc/howto/descriptor.rst:36
msgid "Primer"
msgstr ""
#: ../Doc/howto/descriptor.rst:38
msgid ""
"In this primer, we start with the most basic possible example and then we'll "
"add new capabilities one by one."
msgstr ""
#: ../Doc/howto/descriptor.rst:43
msgid "Simple example: A descriptor that returns a constant"
msgstr ""
#: ../Doc/howto/descriptor.rst:45
msgid ""
"The :class:`Ten` class is a descriptor that always returns the constant "
"``10`` from its :meth:`__get__` method:"
msgstr ""
#: ../Doc/howto/descriptor.rst:54
msgid ""
"To use the descriptor, it must be stored as a class variable in another "
"class:"
msgstr ""
#: ../Doc/howto/descriptor.rst:62
msgid ""
"An interactive session shows the difference between normal attribute lookup "
"and descriptor lookup:"
msgstr ""
#: ../Doc/howto/descriptor.rst:73
msgid ""
"In the ``a.x`` attribute lookup, the dot operator finds the key ``x`` and "
"the value ``5`` in the class dictionary. In the ``a.y`` lookup, the dot "
"operator finds a descriptor instance, recognized by its ``__get__`` method, "
"and calls that method which returns ``10``."
msgstr ""
#: ../Doc/howto/descriptor.rst:78
msgid ""
"Note that the value ``10`` is not stored in either the class dictionary or "
"the instance dictionary. Instead, the value ``10`` is computed on demand."
msgstr ""
#: ../Doc/howto/descriptor.rst:81
msgid ""
"This example shows how a simple descriptor works, but it isn't very useful. "
"For retrieving constants, normal attribute lookup would be better."
msgstr ""
#: ../Doc/howto/descriptor.rst:84
msgid ""
"In the next section, we'll create something more useful, a dynamic lookup."
msgstr ""
#: ../Doc/howto/descriptor.rst:88
msgid "Dynamic lookups"
msgstr ""
#: ../Doc/howto/descriptor.rst:90
msgid ""
"Interesting descriptors typically run computations instead of returning "
"constants:"
msgstr ""
#: ../Doc/howto/descriptor.rst:109
msgid ""
"An interactive session shows that the lookup is dynamic — it computes "
"different, updated answers each time::"
msgstr ""
#: ../Doc/howto/descriptor.rst:122
msgid ""
"Besides showing how descriptors can run computations, this example also "
"reveals the purpose of the parameters to :meth:`__get__`. The *self* "
"parameter is *size*, an instance of *DirectorySize*. The *obj* parameter is "
"either *g* or *s*, an instance of *Directory*. It is the *obj* parameter "
"that lets the :meth:`__get__` method learn the target directory. The "
"*objtype* parameter is the class *Directory*."
msgstr ""
#: ../Doc/howto/descriptor.rst:131
msgid "Managed attributes"
msgstr ""
#: ../Doc/howto/descriptor.rst:133
msgid ""
"A popular use for descriptors is managing access to instance data. The "
"descriptor is assigned to a public attribute in the class dictionary while "
"the actual data is stored as a private attribute in the instance "
"dictionary. The descriptor's :meth:`__get__` and :meth:`__set__` methods "
"are triggered when the public attribute is accessed."
msgstr ""
#: ../Doc/howto/descriptor.rst:139
msgid ""
"In the following example, *age* is the public attribute and *_age* is the "
"private attribute. When the public attribute is accessed, the descriptor "
"logs the lookup or update:"
msgstr ""
#: ../Doc/howto/descriptor.rst:172
msgid ""
"An interactive session shows that all access to the managed attribute *age* "
"is logged, but that the regular attribute *name* is not logged:"
msgstr ""
#: ../Doc/howto/descriptor.rst:206
msgid ""
"One major issue with this example is that the private name *_age* is "
"hardwired in the *LoggedAgeAccess* class. That means that each instance can "
"only have one logged attribute and that its name is unchangeable. In the "
"next example, we'll fix that problem."
msgstr ""
#: ../Doc/howto/descriptor.rst:213
msgid "Customized names"
msgstr ""
#: ../Doc/howto/descriptor.rst:215
msgid ""
"When a class uses descriptors, it can inform each descriptor about which "
"variable name was used."
msgstr ""
#: ../Doc/howto/descriptor.rst:218
msgid ""
"In this example, the :class:`Person` class has two descriptor instances, "
"*name* and *age*. When the :class:`Person` class is defined, it makes a "
"callback to :meth:`__set_name__` in *LoggedAccess* so that the field names "
"can be recorded, giving each descriptor its own *public_name* and "
"*private_name*:"
msgstr ""
#: ../Doc/howto/descriptor.rst:256
msgid ""
"An interactive session shows that the :class:`Person` class has called :meth:"
"`__set_name__` so that the field names would be recorded. Here we call :"
"func:`vars` to look up the descriptor without triggering it:"
msgstr ""
#: ../Doc/howto/descriptor.rst:267
msgid "The new class now logs access to both *name* and *age*:"
msgstr ""
#: ../Doc/howto/descriptor.rst:284
msgid "The two *Person* instances contain only the private names::"
msgstr ""
#: ../Doc/howto/descriptor.rst:293
msgid "Closing thoughts"
msgstr ""
#: ../Doc/howto/descriptor.rst:295
msgid ""
"A :term:`descriptor` is what we call any object that defines :meth:"
"`__get__`, :meth:`__set__`, or :meth:`__delete__`."
msgstr ""
#: ../Doc/howto/descriptor.rst:298
msgid ""
"Optionally, descriptors can have a :meth:`__set_name__` method. This is "
"only used in cases where a descriptor needs to know either the class where "
"it was created or the name of class variable it was assigned to. (This "
"method, if present, is called even if the class is not a descriptor.)"
msgstr ""
#: ../Doc/howto/descriptor.rst:303
msgid ""
"Descriptors get invoked by the dot \"operator\" during attribute lookup. If "
"a descriptor is accessed indirectly with ``vars(some_class)"
"[descriptor_name]``, the descriptor instance is returned without invoking it."
msgstr ""
#: ../Doc/howto/descriptor.rst:307
msgid ""
"Descriptors only work when used as class variables. When put in instances, "
"they have no effect."
msgstr ""
#: ../Doc/howto/descriptor.rst:310
msgid ""
"The main motivation for descriptors is to provide a hook allowing objects "
"stored in class variables to control what happens during attribute lookup."
msgstr ""
#: ../Doc/howto/descriptor.rst:313
msgid ""
"Traditionally, the calling class controls what happens during lookup. "
"Descriptors invert that relationship and allow the data being looked-up to "
"have a say in the matter."
msgstr ""
#: ../Doc/howto/descriptor.rst:317
msgid ""
"Descriptors are used throughout the language. It is how functions turn into "
"bound methods. Common tools like :func:`classmethod`, :func:"
"`staticmethod`, :func:`property`, and :func:`functools.cached_property` are "
"all implemented as descriptors."
msgstr ""
#: ../Doc/howto/descriptor.rst:324
msgid "Complete Practical Example"
msgstr ""
#: ../Doc/howto/descriptor.rst:326
msgid ""
"In this example, we create a practical and powerful tool for locating "
"notoriously hard to find data corruption bugs."
msgstr ""
#: ../Doc/howto/descriptor.rst:331
msgid "Validator class"
msgstr ""
#: ../Doc/howto/descriptor.rst:333
msgid ""
"A validator is a descriptor for managed attribute access. Prior to storing "
"any data, it verifies that the new value meets various type and range "
"restrictions. If those restrictions aren't met, it raises an exception to "
"prevent data corruption at its source."
msgstr ""
#: ../Doc/howto/descriptor.rst:338
msgid ""
"This :class:`Validator` class is both an :term:`abstract base class` and a "
"managed attribute descriptor:"
msgstr ""
#: ../Doc/howto/descriptor.rst:361
msgid ""
"Custom validators need to inherit from :class:`Validator` and must supply a :"
"meth:`validate` method to test various restrictions as needed."
msgstr ""
#: ../Doc/howto/descriptor.rst:366
msgid "Custom validators"
msgstr ""
#: ../Doc/howto/descriptor.rst:368
msgid "Here are three practical data validation utilities:"
msgstr ""
#: ../Doc/howto/descriptor.rst:370
msgid ""
":class:`OneOf` verifies that a value is one of a restricted set of options."
msgstr ""
#: ../Doc/howto/descriptor.rst:372
msgid ""
":class:`Number` verifies that a value is either an :class:`int` or :class:"
"`float`. Optionally, it verifies that a value is between a given minimum or "
"maximum."
msgstr ""
#: ../Doc/howto/descriptor.rst:376
msgid ""
":class:`String` verifies that a value is a :class:`str`. Optionally, it "
"validates a given minimum or maximum length. It can validate a user-defined "
"`predicate <https://en.wikipedia.org/wiki/Predicate_(mathematical_logic)>`_ "
"as well."
msgstr ""
#: ../Doc/howto/descriptor.rst:435
msgid "Practical application"
msgstr ""
#: ../Doc/howto/descriptor.rst:437
msgid "Here's how the data validators can be used in a real class:"
msgstr ""
#: ../Doc/howto/descriptor.rst:452
msgid "The descriptors prevent invalid instances from being created:"
msgstr ""
#: ../Doc/howto/descriptor.rst:479
msgid "Technical Tutorial"
msgstr ""
#: ../Doc/howto/descriptor.rst:481
msgid ""
"What follows is a more technical tutorial for the mechanics and details of "
"how descriptors work."
msgstr ""
#: ../Doc/howto/descriptor.rst:486
msgid "Abstract"
msgstr "Resumen"
#: ../Doc/howto/descriptor.rst:488
msgid ""
"Defines descriptors, summarizes the protocol, and shows how descriptors are "
"called. Provides an example showing how object relational mappings work."
msgstr ""
#: ../Doc/howto/descriptor.rst:491
#, fuzzy
msgid ""
"Learning about descriptors not only provides access to a larger toolset, it "
"creates a deeper understanding of how Python works."
msgstr ""
"Aprender acerca de los descriptores no solo brinda acceso a un conjunto de "
"herramientas mayor, sino que genera una comprensión más profunda de como "
"funciona Python y una apreciación sobre la elegancia de su diseño."
#: ../Doc/howto/descriptor.rst:496
#, fuzzy
msgid "Definition and introduction"
msgstr "Definición e introducción"
#: ../Doc/howto/descriptor.rst:498
msgid ""
"In general, a descriptor is an attribute value that has one of the methods "
"in the descriptor protocol. Those methods are :meth:`__get__`, :meth:"
"`__set__`, and :meth:`__delete__`. If any of those methods are defined for "
"an attribute, it is said to be a :term:`descriptor`."
msgstr ""
#: ../Doc/howto/descriptor.rst:503
#, fuzzy
msgid ""
"The default behavior for attribute access is to get, set, or delete the "
"attribute from an object's dictionary. For instance, ``a.x`` has a lookup "
"chain starting with ``a.__dict__['x']``, then ``type(a).__dict__['x']``, and "
"continuing through the method resolution order of ``type(a)``. If the looked-"
"up value is an object defining one of the descriptor methods, then Python "
"may override the default behavior and invoke the descriptor method instead. "
"Where this occurs in the precedence chain depends on which descriptor "
"methods were defined."
msgstr ""
"El comportamiento predeterminado para el acceso a los atributos es obtener, "
"establecer o eliminar el atributo del diccionario de un objeto. Por ejemplo, "
"``a.x`` tiene una cadena de búsqueda que comienza con ``a.__dict__['x']``, "
"luego ``type(a).__dict__['x']`` y continúa a través de las clases base de "
"``type(a)`` excluyendo metaclases. Si el valor buscado es un objeto que "
"define uno de los métodos del descriptor, entonces Python puede anular el "
"comportamiento predeterminado e invocar el método del descriptor en su "
"lugar. El lugar donde ésto ocurre en la cadena de precedencia depende de qué "
"métodos del descriptor fueron definidos."
#: ../Doc/howto/descriptor.rst:512
msgid ""
"Descriptors are a powerful, general purpose protocol. They are the "
"mechanism behind properties, methods, static methods, class methods, and :"
"func:`super()`. They are used throughout Python itself. Descriptors "
"simplify the underlying C code and offer a flexible set of new tools for "
"everyday Python programs."
msgstr ""
#: ../Doc/howto/descriptor.rst:520
#, fuzzy
msgid "Descriptor protocol"
msgstr "Protocolo descriptor"
#: ../Doc/howto/descriptor.rst:522
msgid "``descr.__get__(self, obj, type=None) -> value``"
msgstr "``descr.__get__(self, obj, type=None) -> value``"
#: ../Doc/howto/descriptor.rst:524
msgid "``descr.__set__(self, obj, value) -> None``"
msgstr "``descr.__set__(self, obj, value) -> None``"
#: ../Doc/howto/descriptor.rst:526
msgid "``descr.__delete__(self, obj) -> None``"
msgstr "``descr.__delete__(self, obj) -> None``"
#: ../Doc/howto/descriptor.rst:528
msgid ""
"That is all there is to it. Define any of these methods and an object is "
"considered a descriptor and can override default behavior upon being looked "
"up as an attribute."
msgstr ""
"Eso es todo lo que hay que hacer. Si se define cualquiera de estos métodos, "
"el objeto se considera un descriptor y puede anular el comportamiento "
"predeterminado al ser buscado como un atributo."
#: ../Doc/howto/descriptor.rst:532
#, fuzzy
msgid ""
"If an object defines :meth:`__set__` or :meth:`__delete__`, it is considered "
"a data descriptor. Descriptors that only define :meth:`__get__` are called "
"non-data descriptors (they are often used for methods but other uses are "
"possible)."
msgstr ""
"Si un objeto define :meth:`__set__` o :meth:`__delete__`, se considera un "
"descriptor de datos. Los descriptores que solo definen :meth:`__get__` se "
"denominan descriptores de no-datos (normalmente se utilizan para métodos, "
"pero son posibles otros usos)."
#: ../Doc/howto/descriptor.rst:537
msgid ""
"Data and non-data descriptors differ in how overrides are calculated with "
"respect to entries in an instance's dictionary. If an instance's dictionary "
"has an entry with the same name as a data descriptor, the data descriptor "
"takes precedence. If an instance's dictionary has an entry with the same "
"name as a non-data descriptor, the dictionary entry takes precedence."
msgstr ""
"Los descriptores de datos y de no-datos difieren en como se calculan las "
"anulaciones con respecto a las entradas en el diccionario de una instancia. "
"Si el diccionario de una instancia tiene una entrada con el mismo nombre que "
"un descriptor de datos, el descriptor de datos tiene prioridad. Si el "
"diccionario de una instancia tiene una entrada con el mismo nombre que un "
"descriptor de no-datos, la entrada del diccionario tiene prioridad."
#: ../Doc/howto/descriptor.rst:543
msgid ""
"To make a read-only data descriptor, define both :meth:`__get__` and :meth:"
"`__set__` with the :meth:`__set__` raising an :exc:`AttributeError` when "
"called. Defining the :meth:`__set__` method with an exception raising "
"placeholder is enough to make it a data descriptor."
msgstr ""
"Para crear un descriptor de datos de solo lectura, se define tanto :meth:"
"`__get__` como :meth:`__set__` donde :meth:`__set__` lanza un error :exc:"
"`AttributeError` cuando es llamado. Definir el método :meth:`__set__` de "
"forma que lance una excepción genérica es suficiente para convertirlo en un "
"descriptor de datos."
#: ../Doc/howto/descriptor.rst:550
msgid "Overview of descriptor invocation"
msgstr ""
#: ../Doc/howto/descriptor.rst:552
#, fuzzy
msgid ""
"A descriptor can be called directly with ``desc.__get__(obj)`` or ``desc."
"__get__(None, cls)``."
msgstr ""
"Un descriptor puede ser llamado directamente mediante el nombre de su "
"método. Por ejemplo ``d.__get__(obj)``."
#: ../Doc/howto/descriptor.rst:555
msgid ""
"But it is more common for a descriptor to be invoked automatically from "
"attribute access."
msgstr ""
#: ../Doc/howto/descriptor.rst:558
msgid ""
"The expression ``obj.x`` looks up the attribute ``x`` in the chain of "
"namespaces for ``obj``. If the search finds a descriptor outside of the "
"instance ``__dict__``, its :meth:`__get__` method is invoked according to "
"the precedence rules listed below."
msgstr ""
#: ../Doc/howto/descriptor.rst:563
#, fuzzy
msgid ""
"The details of invocation depend on whether ``obj`` is an object, class, or "
"instance of super."
msgstr ""
"Los detalles de la invocación dependen de si ``obj`` es un objeto o una "
"clase."
#: ../Doc/howto/descriptor.rst:568
msgid "Invocation from an instance"
msgstr ""
#: ../Doc/howto/descriptor.rst:570
msgid ""
"Instance lookup scans through a chain of namespaces giving data descriptors "
"the highest priority, followed by instance variables, then non-data "
"descriptors, then class variables, and lastly :meth:`__getattr__` if it is "
"provided."
msgstr ""
#: ../Doc/howto/descriptor.rst:575
msgid ""
"If a descriptor is found for ``a.x``, then it is invoked with: ``desc."
"__get__(a, type(a))``."
msgstr ""
#: ../Doc/howto/descriptor.rst:578
msgid ""
"The logic for a dotted lookup is in :meth:`object.__getattribute__`. Here "
"is a pure Python equivalent:"
msgstr ""
#: ../Doc/howto/descriptor.rst:698
msgid ""
"Interestingly, attribute lookup doesn't call :meth:`object.__getattribute__` "
"directly. Instead, both the dot operator and the :func:`getattr` function "
"perform attribute lookup by way of a helper function:"
msgstr ""
#: ../Doc/howto/descriptor.rst:713
msgid ""
"So if :meth:`__getattr__` exists, it is called whenever :meth:"
"`__getattribute__` raises :exc:`AttributeError` (either directly or in one "
"of the descriptor calls)."
msgstr ""
#: ../Doc/howto/descriptor.rst:716
msgid ""
"Also, if a user calls :meth:`object.__getattribute__` directly, the :meth:"
"`__getattr__` hook is bypassed entirely."
msgstr ""
#: ../Doc/howto/descriptor.rst:721
#, fuzzy
msgid "Invocation from a class"
msgstr "Llamado desde una clase"
#: ../Doc/howto/descriptor.rst:723
msgid ""
"The logic for a dotted lookup such as ``A.x`` is in :meth:`type."
"__getattribute__`. The steps are similar to those for :meth:`object."
"__getattribute__` but the instance dictionary lookup is replaced by a search "
"through the class's :term:`method resolution order`."
msgstr ""
#: ../Doc/howto/descriptor.rst:728
msgid "If a descriptor is found, it is invoked with ``desc.__get__(None, A)``."
msgstr ""
#: ../Doc/howto/descriptor.rst:730
msgid ""
"The full C implementation can be found in :c:func:`type_getattro()` and :c:"
"func:`_PyType_Lookup()` in :source:`Objects/typeobject.c`."
msgstr ""
#: ../Doc/howto/descriptor.rst:735
msgid "Invocation from super"
msgstr ""
#: ../Doc/howto/descriptor.rst:737
msgid ""
"The logic for super's dotted lookup is in the :meth:`__getattribute__` "
"method for object returned by :class:`super()`."
msgstr ""
#: ../Doc/howto/descriptor.rst:740
msgid ""
"A dotted lookup such as ``super(A, obj).m`` searches ``obj.__class__."
"__mro__`` for the base class ``B`` immediately following ``A`` and then "
"returns ``B.__dict__['m'].__get__(obj, A)``. If not a descriptor, ``m`` is "
"returned unchanged."
msgstr ""
#: ../Doc/howto/descriptor.rst:745
#, fuzzy
msgid ""
"The full C implementation can be found in :c:func:`super_getattro()` in :"
"source:`Objects/typeobject.c`. A pure Python equivalent can be found in "
"`Guido's Tutorial <https://www.python.org/download/releases/2.2.3/descrintro/"
"#cooperation>`_."
msgstr ""
"Los detalles de la implementación están en :c:func:`super_getattro()` en :"
"source:`Objects/typeobject.c` y un equivalente puro de Python se puede "
"encontrar en el `Guido's Tutorial`_."
#: ../Doc/howto/descriptor.rst:752
msgid "Summary of invocation logic"
msgstr ""
#: ../Doc/howto/descriptor.rst:754
msgid ""
"The mechanism for descriptors is embedded in the :meth:`__getattribute__()` "
"methods for :class:`object`, :class:`type`, and :func:`super`."
msgstr ""
#: ../Doc/howto/descriptor.rst:757
msgid "The important points to remember are:"
msgstr "Los puntos importantes a recordar son:"
#: ../Doc/howto/descriptor.rst:759
#, fuzzy
msgid "Descriptors are invoked by the :meth:`__getattribute__` method."
msgstr "los descriptores son invocados por el método :meth:`__getattribute__`"
#: ../Doc/howto/descriptor.rst:761
msgid ""
"Classes inherit this machinery from :class:`object`, :class:`type`, or :func:"
"`super`."
msgstr ""
#: ../Doc/howto/descriptor.rst:764
#, fuzzy
msgid ""
"Overriding :meth:`__getattribute__` prevents automatic descriptor calls "
"because all the descriptor logic is in that method."
msgstr ""
"redefinir :meth:`__getattribute__` evita las llamadas automáticas al "
"descriptor"
#: ../Doc/howto/descriptor.rst:767
#, fuzzy
msgid ""
":meth:`object.__getattribute__` and :meth:`type.__getattribute__` make "
"different calls to :meth:`__get__`. The first includes the instance and may "
"include the class. The second puts in ``None`` for the instance and always "
"includes the class."
msgstr ""
":meth:`object.__getattribute__` y :meth:`type.__getattribute__` realizan "
"diferentes llamadas a :meth:`__get__`."
#: ../Doc/howto/descriptor.rst:772
#, fuzzy
msgid "Data descriptors always override instance dictionaries."
msgstr ""
"los descriptores de datos siempre anulan los diccionarios de instancia."
#: ../Doc/howto/descriptor.rst:774
#, fuzzy
msgid "Non-data descriptors may be overridden by instance dictionaries."
msgstr ""
"los descriptores de no-datos pueden ser reemplazados por los diccionarios de "
"instancia."
#: ../Doc/howto/descriptor.rst:778
msgid "Automatic name notification"
msgstr ""
#: ../Doc/howto/descriptor.rst:780
msgid ""
"Sometimes it is desirable for a descriptor to know what class variable name "
"it was assigned to. When a new class is created, the :class:`type` "
"metaclass scans the dictionary of the new class. If any of the entries are "
"descriptors and if they define :meth:`__set_name__`, that method is called "
"with two arguments. The *owner* is the class where the descriptor is used, "
"and the *name* is the class variable the descriptor was assigned to."
msgstr ""
#: ../Doc/howto/descriptor.rst:787
#, fuzzy
msgid ""
"The implementation details are in :c:func:`type_new()` and :c:func:"
"`set_names()` in :source:`Objects/typeobject.c`."
msgstr ""
"Los detalles de la implementación están en :c:func:`super_getattro()` en :"
"source:`Objects/typeobject.c` y un equivalente puro de Python se puede "
"encontrar en el `Guido's Tutorial`_."
#: ../Doc/howto/descriptor.rst:790
msgid ""
"Since the update logic is in :meth:`type.__new__`, notifications only take "
"place at the time of class creation. If descriptors are added to the class "
"afterwards, :meth:`__set_name__` will need to be called manually."
msgstr ""
#: ../Doc/howto/descriptor.rst:796
#, fuzzy
msgid "ORM example"
msgstr "Ejemplo de descriptor"
#: ../Doc/howto/descriptor.rst:798
#, python-format
msgid ""
"The following code is simplified skeleton showing how data descriptors could "
"be used to implement an `object relational mapping <https://en.wikipedia.org/"
"wiki/Object%E2%80%93relational_mapping>`_."
msgstr ""
#: ../Doc/howto/descriptor.rst:802
msgid ""
"The essential idea is that the data is stored in an external database. The "
"Python instances only hold keys to the database's tables. Descriptors take "
"care of lookups or updates:"
msgstr ""
#: ../Doc/howto/descriptor.rst:821
msgid ""
"We can use the :class:`Field` class to define `models <https://en.wikipedia."
"org/wiki/Database_model>`_ that describe the schema for each table in a "
"database:"
msgstr ""
#: ../Doc/howto/descriptor.rst:846
msgid "To use the models, first connect to the database::"
msgstr ""
#: ../Doc/howto/descriptor.rst:851
msgid ""
"An interactive session shows how data is retrieved from the database and how "
"it can be updated:"
msgstr ""
#: ../Doc/howto/descriptor.rst:896
msgid "Pure Python Equivalents"
msgstr ""
#: ../Doc/howto/descriptor.rst:898
msgid ""
"The descriptor protocol is simple and offers exciting possibilities. "
"Several use cases are so common that they have been prepackaged into built-"
"in tools. Properties, bound methods, static methods, class methods, and \\_"
"\\_slots\\_\\_ are all based on the descriptor protocol."
msgstr ""
#: ../Doc/howto/descriptor.rst:905
msgid "Properties"
msgstr "Propiedades"
#: ../Doc/howto/descriptor.rst:907
#, fuzzy
msgid ""
"Calling :func:`property` is a succinct way of building a data descriptor "
"that triggers a function call upon access to an attribute. Its signature "
"is::"
msgstr ""
"Llamar a :func:`property` es una forma sucinta de construir un descriptor de "
"datos que desencadena llamadas a funciones al acceder a un atributo. Su "
"firma es::"
#: ../Doc/howto/descriptor.rst:912
#, fuzzy
msgid ""
"The documentation shows a typical use to define a managed attribute ``x``:"
msgstr ""
"La documentación muestra un uso típico para definir un atributo administrado "
"``x``::"
#: ../Doc/howto/descriptor.rst:922
#, fuzzy
msgid ""
"To see how :func:`property` is implemented in terms of the descriptor "
"protocol, here is a pure Python equivalent:"
msgstr ""
"Para ver cómo se implementa :func:`property` en términos del protocolo "
"descriptor, aquí hay un equivalente puro de Python::"
#: ../Doc/howto/descriptor.rst:1015
msgid ""
"The :func:`property` builtin helps whenever a user interface has granted "
"attribute access and then subsequent changes require the intervention of a "
"method."
msgstr ""
"La función incorporada :func:`property` es de ayuda cuando una interfaz de "
"usuario ha otorgado acceso a atributos y luego los cambios posteriores "
"requieren la intervención de un método."
#: ../Doc/howto/descriptor.rst:1019
#, fuzzy
msgid ""
"For instance, a spreadsheet class may grant access to a cell value through "
"``Cell('b10').value``. Subsequent improvements to the program require the "
"cell to be recalculated on every access; however, the programmer does not "
"want to affect existing client code accessing the attribute directly. The "
"solution is to wrap access to the value attribute in a property data "
"descriptor:"
msgstr ""
"Por ejemplo, una clase de hoja de cálculo puede otorgar acceso al valor de "
"una celda a través de ``Cell('b10').value``. Las mejoras posteriores del "
"programa requieren que la celda se vuelva a calcular en cada acceso; sin "
"embargo, el programador no quiere afectar al código de cliente existente que "
"accede al atributo directamente. La solución es envolver el acceso al valor "
"del atributo en un descriptor de datos mediante una propiedad::"
#: ../Doc/howto/descriptor.rst:1036
msgid ""
"Either the built-in :func:`property` or our :func:`Property` equivalent "
"would work in this example."
msgstr ""
#: ../Doc/howto/descriptor.rst:1041
#, fuzzy
msgid "Functions and methods"
msgstr "Funciones y métodos"
#: ../Doc/howto/descriptor.rst:1043
msgid ""
"Python's object oriented features are built upon a function based "
"environment. Using non-data descriptors, the two are merged seamlessly."
msgstr ""
"Las características orientadas a objetos de Python se basan en un entorno "
"basado en funciones. Usando descriptores de no-datos, ambas se combinan "
"perfectamente."
#: ../Doc/howto/descriptor.rst:1046
msgid ""
"Functions stored in class dictionaries get turned into methods when invoked. "
"Methods only differ from regular functions in that the object instance is "
"prepended to the other arguments. By convention, the instance is called "
"*self* but could be called *this* or any other variable name."
msgstr ""
#: ../Doc/howto/descriptor.rst:1051
msgid ""
"Methods can be created manually with :class:`types.MethodType` which is "
"roughly equivalent to:"
msgstr ""
#: ../Doc/howto/descriptor.rst:1068
msgid ""
"To support automatic creation of methods, functions include the :meth:"
"`__get__` method for binding methods during attribute access. This means "
"that functions are non-data descriptors that return bound methods during "
"dotted lookup from an instance. Here's how it works:"
msgstr ""
#: ../Doc/howto/descriptor.rst:1084
#, fuzzy
msgid ""
"Running the following class in the interpreter shows how the function "
"descriptor works in practice:"
msgstr ""
"Ejecutar el intérprete muestra como funciona el descriptor de función en la "
"práctica::"
#: ../Doc/howto/descriptor.rst:1093
msgid ""
"The function has a :term:`qualified name` attribute to support introspection:"
msgstr ""
#: ../Doc/howto/descriptor.rst:1100
msgid ""
"Accessing the function through the class dictionary does not invoke :meth:"
"`__get__`. Instead, it just returns the underlying function object::"
msgstr ""
#: ../Doc/howto/descriptor.rst:1106
msgid ""
"Dotted access from a class calls :meth:`__get__` which just returns the "
"underlying function unchanged::"
msgstr ""
#: ../Doc/howto/descriptor.rst:1112
msgid ""
"The interesting behavior occurs during dotted access from an instance. The "
"dotted lookup calls :meth:`__get__` which returns a bound method object::"
msgstr ""
#: ../Doc/howto/descriptor.rst:1119
msgid ""
"Internally, the bound method stores the underlying function and the bound "
"instance::"
msgstr ""
#: ../Doc/howto/descriptor.rst:1128
msgid ""
"If you have ever wondered where *self* comes from in regular methods or "
"where *cls* comes from in class methods, this is it!"
msgstr ""
#: ../Doc/howto/descriptor.rst:1133
msgid "Other kinds of methods"
msgstr ""
#: ../Doc/howto/descriptor.rst:1135
msgid ""
"Non-data descriptors provide a simple mechanism for variations on the usual "
"patterns of binding functions into methods."
msgstr ""
"Los descriptores de no-datos proporcionan un mecanismo simple para "
"variaciones de los patrones habituales para vincular funciones en métodos."
#: ../Doc/howto/descriptor.rst:1138
#, fuzzy
msgid ""
"To recap, functions have a :meth:`__get__` method so that they can be "
"converted to a method when accessed as attributes. The non-data descriptor "
"transforms an ``obj.f(*args)`` call into ``f(obj, *args)``. Calling ``cls."
"f(*args)`` becomes ``f(*args)``."
msgstr ""
"En resumen, las funciones tienen un método :meth:`__get__` para que se "
"puedan convertir en un método cuando se accede a ellas como atributos. El "
"descriptor de no-datos transforma una llamada a ``obj.f(*args)`` en ``f(obj, "
"*args)``. Llamar a ``klass.f(*args)`` se convierte en ``f(*args)``."
#: ../Doc/howto/descriptor.rst:1143
msgid "This chart summarizes the binding and its two most useful variants:"
msgstr ""
"Este cuadro resume el enlace (*binding*) y sus dos variantes más útiles:"
#: ../Doc/howto/descriptor.rst:1146
msgid "Transformation"
msgstr "Transformación"
#: ../Doc/howto/descriptor.rst:1146
#, fuzzy
msgid "Called from an object"
msgstr "Llamado desde un objeto"
#: ../Doc/howto/descriptor.rst:1146
#, fuzzy
msgid "Called from a class"
msgstr "Llamado desde una clase"
#: ../Doc/howto/descriptor.rst:1149
msgid "function"
msgstr "función"
#: ../Doc/howto/descriptor.rst:1149
msgid "f(obj, \\*args)"
msgstr "f(obj, \\*args)"
#: ../Doc/howto/descriptor.rst:1149 ../Doc/howto/descriptor.rst:1151
msgid "f(\\*args)"
msgstr "f(\\*args)"
#: ../Doc/howto/descriptor.rst:1151
msgid "staticmethod"
msgstr "método estático"
#: ../Doc/howto/descriptor.rst:1153
msgid "classmethod"
msgstr "método de clase"
#: ../Doc/howto/descriptor.rst:1153
msgid "f(type(obj), \\*args)"
msgstr "f(type(obj), \\*args)"
#: ../Doc/howto/descriptor.rst:1153
#, fuzzy
msgid "f(cls, \\*args)"
msgstr "f(klass, \\*args)"
#: ../Doc/howto/descriptor.rst:1158
#, fuzzy
msgid "Static methods"
msgstr "método estático"
#: ../Doc/howto/descriptor.rst:1160
msgid ""
"Static methods return the underlying function without changes. Calling "