-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcollections.po
1543 lines (1301 loc) · 50.5 KB
/
collections.po
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
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2001-2025, Python Software Foundation
# This file is distributed under the same license as the Python package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
# Translators:
# Stan Ulbrych, 2025
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.13\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-03-21 14:18+0000\n"
"PO-Revision-Date: 2021-06-28 00:56+0000\n"
"Last-Translator: Stan Ulbrych, 2025\n"
"Language-Team: Polish (https://app.transifex.com/python-doc/teams/5390/pl/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: pl\n"
"Plural-Forms: nplurals=4; plural=(n==1 ? 0 : (n%10>=2 && n%10<=4) && "
"(n%100<12 || n%100>14) ? 1 : n!=1 && (n%10>=0 && n%10<=1) || (n%10>=5 && "
"n%10<=9) || (n%100>=12 && n%100<=14) ? 2 : 3);\n"
msgid ":mod:`!collections` --- Container datatypes"
msgstr ""
msgid "**Source code:** :source:`Lib/collections/__init__.py`"
msgstr "**Kod źródłowy:** :source:`Lib/collections/__init__.py`"
msgid ""
"This module implements specialized container datatypes providing "
"alternatives to Python's general purpose built-in containers, :class:"
"`dict`, :class:`list`, :class:`set`, and :class:`tuple`."
msgstr ""
msgid ":func:`namedtuple`"
msgstr ":func:`namedtuple`"
msgid "factory function for creating tuple subclasses with named fields"
msgstr ""
msgid ":class:`deque`"
msgstr ":class:`deque`"
msgid "list-like container with fast appends and pops on either end"
msgstr ""
msgid ":class:`ChainMap`"
msgstr ":class:`ChainMap`"
msgid "dict-like class for creating a single view of multiple mappings"
msgstr ""
msgid ":class:`Counter`"
msgstr ":class:`Counter`"
msgid "dict subclass for counting :term:`hashable` objects"
msgstr ""
msgid ":class:`OrderedDict`"
msgstr ":class:`OrderedDict`"
msgid "dict subclass that remembers the order entries were added"
msgstr ""
msgid ":class:`defaultdict`"
msgstr ":class:`defaultdict`"
msgid "dict subclass that calls a factory function to supply missing values"
msgstr ""
msgid ":class:`UserDict`"
msgstr ":class:`UserDict`"
msgid "wrapper around dictionary objects for easier dict subclassing"
msgstr ""
msgid ":class:`UserList`"
msgstr ":class:`UserList`"
msgid "wrapper around list objects for easier list subclassing"
msgstr ""
msgid ":class:`UserString`"
msgstr ":class:`UserString`"
msgid "wrapper around string objects for easier string subclassing"
msgstr ""
msgid ":class:`ChainMap` objects"
msgstr ":class:`ChainMap` przedmioty"
msgid ""
"A :class:`ChainMap` class is provided for quickly linking a number of "
"mappings so they can be treated as a single unit. It is often much faster "
"than creating a new dictionary and running multiple :meth:`~dict.update` "
"calls."
msgstr ""
msgid ""
"The class can be used to simulate nested scopes and is useful in templating."
msgstr ""
msgid ""
"A :class:`ChainMap` groups multiple dicts or other mappings together to "
"create a single, updateable view. If no *maps* are specified, a single "
"empty dictionary is provided so that a new chain always has at least one "
"mapping."
msgstr ""
msgid ""
"The underlying mappings are stored in a list. That list is public and can "
"be accessed or updated using the *maps* attribute. There is no other state."
msgstr ""
msgid ""
"Lookups search the underlying mappings successively until a key is found. "
"In contrast, writes, updates, and deletions only operate on the first "
"mapping."
msgstr ""
msgid ""
"A :class:`ChainMap` incorporates the underlying mappings by reference. So, "
"if one of the underlying mappings gets updated, those changes will be "
"reflected in :class:`ChainMap`."
msgstr ""
msgid ""
"All of the usual dictionary methods are supported. In addition, there is a "
"*maps* attribute, a method for creating new subcontexts, and a property for "
"accessing all but the first mapping:"
msgstr ""
msgid ""
"A user updateable list of mappings. The list is ordered from first-searched "
"to last-searched. It is the only stored state and can be modified to change "
"which mappings are searched. The list should always contain at least one "
"mapping."
msgstr ""
msgid ""
"Returns a new :class:`ChainMap` containing a new map followed by all of the "
"maps in the current instance. If ``m`` is specified, it becomes the new map "
"at the front of the list of mappings; if not specified, an empty dict is "
"used, so that a call to ``d.new_child()`` is equivalent to: ``ChainMap({}, "
"*d.maps)``. If any keyword arguments are specified, they update passed map "
"or new empty dict. This method is used for creating subcontexts that can be "
"updated without altering values in any of the parent mappings."
msgstr ""
msgid "The optional ``m`` parameter was added."
msgstr ""
msgid "Keyword arguments support was added."
msgstr ""
msgid ""
"Property returning a new :class:`ChainMap` containing all of the maps in the "
"current instance except the first one. This is useful for skipping the "
"first map in the search. Use cases are similar to those for the :keyword:"
"`nonlocal` keyword used in :term:`nested scopes <nested scope>`. The use "
"cases also parallel those for the built-in :func:`super` function. A "
"reference to ``d.parents`` is equivalent to: ``ChainMap(*d.maps[1:])``."
msgstr ""
msgid ""
"Note, the iteration order of a :class:`ChainMap` is determined by scanning "
"the mappings last to first::"
msgstr ""
msgid ""
">>> baseline = {'music': 'bach', 'art': 'rembrandt'}\n"
">>> adjustments = {'art': 'van gogh', 'opera': 'carmen'}\n"
">>> list(ChainMap(adjustments, baseline))\n"
"['music', 'art', 'opera']"
msgstr ""
msgid ""
"This gives the same ordering as a series of :meth:`dict.update` calls "
"starting with the last mapping::"
msgstr ""
msgid ""
">>> combined = baseline.copy()\n"
">>> combined.update(adjustments)\n"
">>> list(combined)\n"
"['music', 'art', 'opera']"
msgstr ""
">>> combined = baseline.copy()\n"
">>> combined.update(adjustments)\n"
">>> list(combined)\n"
"['music', 'art', 'opera']"
msgid "Added support for ``|`` and ``|=`` operators, specified in :pep:`584`."
msgstr ""
msgid ""
"The `MultiContext class <https://github.com/enthought/codetools/blob/4.0.0/"
"codetools/contexts/multi_context.py>`_ in the Enthought `CodeTools package "
"<https://github.com/enthought/codetools>`_ has options to support writing to "
"any mapping in the chain."
msgstr ""
msgid ""
"Django's `Context class <https://github.com/django/django/blob/main/django/"
"template/context.py>`_ for templating is a read-only chain of mappings. It "
"also features pushing and popping of contexts similar to the :meth:"
"`~collections.ChainMap.new_child` method and the :attr:`~collections."
"ChainMap.parents` property."
msgstr ""
msgid ""
"The `Nested Contexts recipe <https://code.activestate.com/recipes/577434-"
"nested-contexts-a-chain-of-mapping-objects/>`_ has options to control "
"whether writes and other mutations apply only to the first mapping or to any "
"mapping in the chain."
msgstr ""
msgid ""
"A `greatly simplified read-only version of Chainmap <https://code."
"activestate.com/recipes/305268/>`_."
msgstr ""
msgid ":class:`ChainMap` Examples and Recipes"
msgstr ""
msgid "This section shows various approaches to working with chained maps."
msgstr ""
msgid "Example of simulating Python's internal lookup chain::"
msgstr ""
msgid ""
"import builtins\n"
"pylookup = ChainMap(locals(), globals(), vars(builtins))"
msgstr ""
msgid ""
"Example of letting user specified command-line arguments take precedence "
"over environment variables which in turn take precedence over default "
"values::"
msgstr ""
msgid ""
"import os, argparse\n"
"\n"
"defaults = {'color': 'red', 'user': 'guest'}\n"
"\n"
"parser = argparse.ArgumentParser()\n"
"parser.add_argument('-u', '--user')\n"
"parser.add_argument('-c', '--color')\n"
"namespace = parser.parse_args()\n"
"command_line_args = {k: v for k, v in vars(namespace).items() if v is not "
"None}\n"
"\n"
"combined = ChainMap(command_line_args, os.environ, defaults)\n"
"print(combined['color'])\n"
"print(combined['user'])"
msgstr ""
msgid ""
"Example patterns for using the :class:`ChainMap` class to simulate nested "
"contexts::"
msgstr ""
msgid ""
"c = ChainMap() # Create root context\n"
"d = c.new_child() # Create nested child context\n"
"e = c.new_child() # Child of c, independent from d\n"
"e.maps[0] # Current context dictionary -- like Python's "
"locals()\n"
"e.maps[-1] # Root context -- like Python's globals()\n"
"e.parents # Enclosing context chain -- like Python's nonlocals\n"
"\n"
"d['x'] = 1 # Set value in current context\n"
"d['x'] # Get first key in the chain of contexts\n"
"del d['x'] # Delete from current context\n"
"list(d) # All nested values\n"
"k in d # Check all nested values\n"
"len(d) # Number of nested values\n"
"d.items() # All nested items\n"
"dict(d) # Flatten into a regular dictionary"
msgstr ""
msgid ""
"The :class:`ChainMap` class only makes updates (writes and deletions) to the "
"first mapping in the chain while lookups will search the full chain. "
"However, if deep writes and deletions are desired, it is easy to make a "
"subclass that updates keys found deeper in the chain::"
msgstr ""
msgid ""
"class DeepChainMap(ChainMap):\n"
" 'Variant of ChainMap that allows direct updates to inner scopes'\n"
"\n"
" def __setitem__(self, key, value):\n"
" for mapping in self.maps:\n"
" if key in mapping:\n"
" mapping[key] = value\n"
" return\n"
" self.maps[0][key] = value\n"
"\n"
" def __delitem__(self, key):\n"
" for mapping in self.maps:\n"
" if key in mapping:\n"
" del mapping[key]\n"
" return\n"
" raise KeyError(key)\n"
"\n"
">>> d = DeepChainMap({'zebra': 'black'}, {'elephant': 'blue'}, {'lion': "
"'yellow'})\n"
">>> d['lion'] = 'orange' # update an existing key two levels down\n"
">>> d['snake'] = 'red' # new keys get added to the topmost dict\n"
">>> del d['elephant'] # remove an existing key one level down\n"
">>> d # display result\n"
"DeepChainMap({'zebra': 'black', 'snake': 'red'}, {}, {'lion': 'orange'})"
msgstr ""
msgid ":class:`Counter` objects"
msgstr ":class:`Counter` przedmioty"
msgid ""
"A counter tool is provided to support convenient and rapid tallies. For "
"example::"
msgstr ""
msgid ""
">>> # Tally occurrences of words in a list\n"
">>> cnt = Counter()\n"
">>> for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']:\n"
"... cnt[word] += 1\n"
"...\n"
">>> cnt\n"
"Counter({'blue': 3, 'red': 2, 'green': 1})\n"
"\n"
">>> # Find the ten most common words in Hamlet\n"
">>> import re\n"
">>> words = re.findall(r'\\w+', open('hamlet.txt').read().lower())\n"
">>> Counter(words).most_common(10)\n"
"[('the', 1143), ('and', 966), ('to', 762), ('of', 669), ('i', 631),\n"
" ('you', 554), ('a', 546), ('my', 514), ('hamlet', 471), ('in', 451)]"
msgstr ""
msgid ""
"A :class:`Counter` is a :class:`dict` subclass for counting :term:`hashable` "
"objects. It is a collection where elements are stored as dictionary keys and "
"their counts are stored as dictionary values. Counts are allowed to be any "
"integer value including zero or negative counts. The :class:`Counter` class "
"is similar to bags or multisets in other languages."
msgstr ""
msgid ""
"Elements are counted from an *iterable* or initialized from another "
"*mapping* (or counter):"
msgstr ""
msgid ""
"Counter objects have a dictionary interface except that they return a zero "
"count for missing items instead of raising a :exc:`KeyError`:"
msgstr ""
msgid ""
"Setting a count to zero does not remove an element from a counter. Use "
"``del`` to remove it entirely:"
msgstr ""
msgid ""
"As a :class:`dict` subclass, :class:`Counter` inherited the capability to "
"remember insertion order. Math operations on *Counter* objects also "
"preserve order. Results are ordered according to when an element is first "
"encountered in the left operand and then by the order encountered in the "
"right operand."
msgstr ""
msgid ""
"Counter objects support additional methods beyond those available for all "
"dictionaries:"
msgstr ""
msgid ""
"Return an iterator over elements repeating each as many times as its count. "
"Elements are returned in the order first encountered. If an element's count "
"is less than one, :meth:`elements` will ignore it."
msgstr ""
msgid ""
"Return a list of the *n* most common elements and their counts from the most "
"common to the least. If *n* is omitted or ``None``, :meth:`most_common` "
"returns *all* elements in the counter. Elements with equal counts are "
"ordered in the order first encountered:"
msgstr ""
msgid ""
"Elements are subtracted from an *iterable* or from another *mapping* (or "
"counter). Like :meth:`dict.update` but subtracts counts instead of "
"replacing them. Both inputs and outputs may be zero or negative."
msgstr ""
msgid "Compute the sum of the counts."
msgstr ""
msgid ""
"The usual dictionary methods are available for :class:`Counter` objects "
"except for two which work differently for counters."
msgstr ""
msgid "This class method is not implemented for :class:`Counter` objects."
msgstr ""
msgid ""
"Elements are counted from an *iterable* or added-in from another *mapping* "
"(or counter). Like :meth:`dict.update` but adds counts instead of replacing "
"them. Also, the *iterable* is expected to be a sequence of elements, not a "
"sequence of ``(key, value)`` pairs."
msgstr ""
msgid ""
"Counters support rich comparison operators for equality, subset, and "
"superset relationships: ``==``, ``!=``, ``<``, ``<=``, ``>``, ``>=``. All of "
"those tests treat missing elements as having zero counts so that "
"``Counter(a=1) == Counter(a=1, b=0)`` returns true."
msgstr ""
msgid "Rich comparison operations were added."
msgstr ""
msgid ""
"In equality tests, missing elements are treated as having zero counts. "
"Formerly, ``Counter(a=3)`` and ``Counter(a=3, b=0)`` were considered "
"distinct."
msgstr ""
msgid "Common patterns for working with :class:`Counter` objects::"
msgstr ""
msgid ""
"c.total() # total of all counts\n"
"c.clear() # reset all counts\n"
"list(c) # list unique elements\n"
"set(c) # convert to a set\n"
"dict(c) # convert to a regular dictionary\n"
"c.items() # access the (elem, cnt) pairs\n"
"Counter(dict(list_of_pairs)) # convert from a list of (elem, cnt) pairs\n"
"c.most_common()[:-n-1:-1] # n least common elements\n"
"+c # remove zero and negative counts"
msgstr ""
msgid ""
"Several mathematical operations are provided for combining :class:`Counter` "
"objects to produce multisets (counters that have counts greater than zero). "
"Addition and subtraction combine counters by adding or subtracting the "
"counts of corresponding elements. Intersection and union return the minimum "
"and maximum of corresponding counts. Equality and inclusion compare "
"corresponding counts. Each operation can accept inputs with signed counts, "
"but the output will exclude results with counts of zero or less."
msgstr ""
msgid ""
">>> c = Counter(a=3, b=1)\n"
">>> d = Counter(a=1, b=2)\n"
">>> c + d # add two counters together: c[x] + d[x]\n"
"Counter({'a': 4, 'b': 3})\n"
">>> c - d # subtract (keeping only positive counts)\n"
"Counter({'a': 2})\n"
">>> c & d # intersection: min(c[x], d[x])\n"
"Counter({'a': 1, 'b': 1})\n"
">>> c | d # union: max(c[x], d[x])\n"
"Counter({'a': 3, 'b': 2})\n"
">>> c == d # equality: c[x] == d[x]\n"
"False\n"
">>> c <= d # inclusion: c[x] <= d[x]\n"
"False"
msgstr ""
msgid ""
"Unary addition and subtraction are shortcuts for adding an empty counter or "
"subtracting from an empty counter."
msgstr ""
msgid ""
"Added support for unary plus, unary minus, and in-place multiset operations."
msgstr ""
msgid ""
"Counters were primarily designed to work with positive integers to represent "
"running counts; however, care was taken to not unnecessarily preclude use "
"cases needing other types or negative values. To help with those use cases, "
"this section documents the minimum range and type restrictions."
msgstr ""
msgid ""
"The :class:`Counter` class itself is a dictionary subclass with no "
"restrictions on its keys and values. The values are intended to be numbers "
"representing counts, but you *could* store anything in the value field."
msgstr ""
msgid ""
"The :meth:`~Counter.most_common` method requires only that the values be "
"orderable."
msgstr ""
msgid ""
"For in-place operations such as ``c[key] += 1``, the value type need only "
"support addition and subtraction. So fractions, floats, and decimals would "
"work and negative values are supported. The same is also true for :meth:"
"`~Counter.update` and :meth:`~Counter.subtract` which allow negative and "
"zero values for both inputs and outputs."
msgstr ""
msgid ""
"The multiset methods are designed only for use cases with positive values. "
"The inputs may be negative or zero, but only outputs with positive values "
"are created. There are no type restrictions, but the value type needs to "
"support addition, subtraction, and comparison."
msgstr ""
msgid ""
"The :meth:`~Counter.elements` method requires integer counts. It ignores "
"zero and negative counts."
msgstr ""
msgid ""
"`Bag class <https://www.gnu.org/software/smalltalk/manual-base/html_node/Bag."
"html>`_ in Smalltalk."
msgstr ""
msgid ""
"Wikipedia entry for `Multisets <https://en.wikipedia.org/wiki/Multiset>`_."
msgstr ""
msgid ""
"`C++ multisets <http://www.java2s.com/Tutorial/Cpp/0380__set-multiset/"
"Catalog0380__set-multiset.htm>`_ tutorial with examples."
msgstr ""
msgid ""
"For mathematical operations on multisets and their use cases, see *Knuth, "
"Donald. The Art of Computer Programming Volume II, Section 4.6.3, Exercise "
"19*."
msgstr ""
msgid ""
"To enumerate all distinct multisets of a given size over a given set of "
"elements, see :func:`itertools.combinations_with_replacement`::"
msgstr ""
msgid ""
"map(Counter, combinations_with_replacement('ABC', 2)) # --> AA AB AC BB BC CC"
msgstr ""
msgid ":class:`deque` objects"
msgstr ":class:`deque` przedmioty"
msgid ""
"Returns a new deque object initialized left-to-right (using :meth:`append`) "
"with data from *iterable*. If *iterable* is not specified, the new deque is "
"empty."
msgstr ""
msgid ""
"Deques are a generalization of stacks and queues (the name is pronounced "
"\"deck\" and is short for \"double-ended queue\"). Deques support thread-"
"safe, memory efficient appends and pops from either side of the deque with "
"approximately the same *O*\\ (1) performance in either direction."
msgstr ""
msgid ""
"Though :class:`list` objects support similar operations, they are optimized "
"for fast fixed-length operations and incur *O*\\ (*n*) memory movement costs "
"for ``pop(0)`` and ``insert(0, v)`` operations which change both the size "
"and position of the underlying data representation."
msgstr ""
msgid ""
"If *maxlen* is not specified or is ``None``, deques may grow to an arbitrary "
"length. Otherwise, the deque is bounded to the specified maximum length. "
"Once a bounded length deque is full, when new items are added, a "
"corresponding number of items are discarded from the opposite end. Bounded "
"length deques provide functionality similar to the ``tail`` filter in Unix. "
"They are also useful for tracking transactions and other pools of data where "
"only the most recent activity is of interest."
msgstr ""
msgid "Deque objects support the following methods:"
msgstr ""
msgid "Add *x* to the right side of the deque."
msgstr ""
msgid "Add *x* to the left side of the deque."
msgstr ""
msgid "Remove all elements from the deque leaving it with length 0."
msgstr ""
msgid "Create a shallow copy of the deque."
msgstr ""
msgid "Count the number of deque elements equal to *x*."
msgstr ""
msgid ""
"Extend the right side of the deque by appending elements from the iterable "
"argument."
msgstr ""
msgid ""
"Extend the left side of the deque by appending elements from *iterable*. "
"Note, the series of left appends results in reversing the order of elements "
"in the iterable argument."
msgstr ""
msgid ""
"Return the position of *x* in the deque (at or after index *start* and "
"before index *stop*). Returns the first match or raises :exc:`ValueError` "
"if not found."
msgstr ""
msgid "Insert *x* into the deque at position *i*."
msgstr ""
msgid ""
"If the insertion would cause a bounded deque to grow beyond *maxlen*, an :"
"exc:`IndexError` is raised."
msgstr ""
msgid ""
"Remove and return an element from the right side of the deque. If no "
"elements are present, raises an :exc:`IndexError`."
msgstr ""
msgid ""
"Remove and return an element from the left side of the deque. If no elements "
"are present, raises an :exc:`IndexError`."
msgstr ""
msgid ""
"Remove the first occurrence of *value*. If not found, raises a :exc:"
"`ValueError`."
msgstr ""
msgid "Reverse the elements of the deque in-place and then return ``None``."
msgstr ""
msgid ""
"Rotate the deque *n* steps to the right. If *n* is negative, rotate to the "
"left."
msgstr ""
msgid ""
"When the deque is not empty, rotating one step to the right is equivalent to "
"``d.appendleft(d.pop())``, and rotating one step to the left is equivalent "
"to ``d.append(d.popleft())``."
msgstr ""
msgid "Deque objects also provide one read-only attribute:"
msgstr ""
msgid "Maximum size of a deque or ``None`` if unbounded."
msgstr ""
msgid ""
"In addition to the above, deques support iteration, pickling, ``len(d)``, "
"``reversed(d)``, ``copy.copy(d)``, ``copy.deepcopy(d)``, membership testing "
"with the :keyword:`in` operator, and subscript references such as ``d[0]`` "
"to access the first element. Indexed access is *O*\\ (1) at both ends but "
"slows to *O*\\ (*n*) in the middle. For fast random access, use lists "
"instead."
msgstr ""
msgid ""
"Starting in version 3.5, deques support ``__add__()``, ``__mul__()``, and "
"``__imul__()``."
msgstr ""
msgid "Example:"
msgstr "Przykład:"
msgid ""
">>> from collections import deque\n"
">>> d = deque('ghi') # make a new deque with three items\n"
">>> for elem in d: # iterate over the deque's elements\n"
"... print(elem.upper())\n"
"G\n"
"H\n"
"I\n"
"\n"
">>> d.append('j') # add a new entry to the right side\n"
">>> d.appendleft('f') # add a new entry to the left side\n"
">>> d # show the representation of the deque\n"
"deque(['f', 'g', 'h', 'i', 'j'])\n"
"\n"
">>> d.pop() # return and remove the rightmost item\n"
"'j'\n"
">>> d.popleft() # return and remove the leftmost item\n"
"'f'\n"
">>> list(d) # list the contents of the deque\n"
"['g', 'h', 'i']\n"
">>> d[0] # peek at leftmost item\n"
"'g'\n"
">>> d[-1] # peek at rightmost item\n"
"'i'\n"
"\n"
">>> list(reversed(d)) # list the contents of a deque in "
"reverse\n"
"['i', 'h', 'g']\n"
">>> 'h' in d # search the deque\n"
"True\n"
">>> d.extend('jkl') # add multiple elements at once\n"
">>> d\n"
"deque(['g', 'h', 'i', 'j', 'k', 'l'])\n"
">>> d.rotate(1) # right rotation\n"
">>> d\n"
"deque(['l', 'g', 'h', 'i', 'j', 'k'])\n"
">>> d.rotate(-1) # left rotation\n"
">>> d\n"
"deque(['g', 'h', 'i', 'j', 'k', 'l'])\n"
"\n"
">>> deque(reversed(d)) # make a new deque in reverse order\n"
"deque(['l', 'k', 'j', 'i', 'h', 'g'])\n"
">>> d.clear() # empty the deque\n"
">>> d.pop() # cannot pop from an empty deque\n"
"Traceback (most recent call last):\n"
" File \"<pyshell#6>\", line 1, in -toplevel-\n"
" d.pop()\n"
"IndexError: pop from an empty deque\n"
"\n"
">>> d.extendleft('abc') # extendleft() reverses the input "
"order\n"
">>> d\n"
"deque(['c', 'b', 'a'])"
msgstr ""
msgid ":class:`deque` Recipes"
msgstr ":class:`deque` Przepisy"
msgid "This section shows various approaches to working with deques."
msgstr ""
msgid ""
"Bounded length deques provide functionality similar to the ``tail`` filter "
"in Unix::"
msgstr ""
msgid ""
"def tail(filename, n=10):\n"
" 'Return the last n lines of a file'\n"
" with open(filename) as f:\n"
" return deque(f, n)"
msgstr ""
msgid ""
"Another approach to using deques is to maintain a sequence of recently added "
"elements by appending to the right and popping to the left::"
msgstr ""
msgid ""
"def moving_average(iterable, n=3):\n"
" # moving_average([40, 30, 50, 46, 39, 44]) --> 40.0 42.0 45.0 43.0\n"
" # https://en.wikipedia.org/wiki/Moving_average\n"
" it = iter(iterable)\n"
" d = deque(itertools.islice(it, n-1))\n"
" d.appendleft(0)\n"
" s = sum(d)\n"
" for elem in it:\n"
" s += elem - d.popleft()\n"
" d.append(elem)\n"
" yield s / n"
msgstr ""
msgid ""
"A `round-robin scheduler <https://en.wikipedia.org/wiki/Round-"
"robin_scheduling>`_ can be implemented with input iterators stored in a :"
"class:`deque`. Values are yielded from the active iterator in position "
"zero. If that iterator is exhausted, it can be removed with :meth:`~deque."
"popleft`; otherwise, it can be cycled back to the end with the :meth:`~deque."
"rotate` method::"
msgstr ""
msgid ""
"def roundrobin(*iterables):\n"
" \"roundrobin('ABC', 'D', 'EF') --> A D E B F C\"\n"
" iterators = deque(map(iter, iterables))\n"
" while iterators:\n"
" try:\n"
" while True:\n"
" yield next(iterators[0])\n"
" iterators.rotate(-1)\n"
" except StopIteration:\n"
" # Remove an exhausted iterator.\n"
" iterators.popleft()"
msgstr ""
msgid ""
"The :meth:`~deque.rotate` method provides a way to implement :class:`deque` "
"slicing and deletion. For example, a pure Python implementation of ``del "
"d[n]`` relies on the ``rotate()`` method to position elements to be popped::"
msgstr ""
msgid ""
"def delete_nth(d, n):\n"
" d.rotate(-n)\n"
" d.popleft()\n"
" d.rotate(n)"
msgstr ""
msgid ""
"To implement :class:`deque` slicing, use a similar approach applying :meth:"
"`~deque.rotate` to bring a target element to the left side of the deque. "
"Remove old entries with :meth:`~deque.popleft`, add new entries with :meth:"
"`~deque.extend`, and then reverse the rotation. With minor variations on "
"that approach, it is easy to implement Forth style stack manipulations such "
"as ``dup``, ``drop``, ``swap``, ``over``, ``pick``, ``rot``, and ``roll``."
msgstr ""
msgid ":class:`defaultdict` objects"
msgstr ":class:`defaultdict` przedmioty"
msgid ""
"Return a new dictionary-like object. :class:`defaultdict` is a subclass of "
"the built-in :class:`dict` class. It overrides one method and adds one "
"writable instance variable. The remaining functionality is the same as for "
"the :class:`dict` class and is not documented here."
msgstr ""
msgid ""
"The first argument provides the initial value for the :attr:"
"`default_factory` attribute; it defaults to ``None``. All remaining "
"arguments are treated the same as if they were passed to the :class:`dict` "
"constructor, including keyword arguments."
msgstr ""
msgid ""
":class:`defaultdict` objects support the following method in addition to the "
"standard :class:`dict` operations:"
msgstr ""
msgid ""
"If the :attr:`default_factory` attribute is ``None``, this raises a :exc:"
"`KeyError` exception with the *key* as argument."
msgstr ""
msgid ""
"If :attr:`default_factory` is not ``None``, it is called without arguments "
"to provide a default value for the given *key*, this value is inserted in "
"the dictionary for the *key*, and returned."
msgstr ""
msgid ""
"If calling :attr:`default_factory` raises an exception this exception is "
"propagated unchanged."
msgstr ""
msgid ""
"This method is called by the :meth:`~object.__getitem__` method of the :"
"class:`dict` class when the requested key is not found; whatever it returns "
"or raises is then returned or raised by :meth:`~object.__getitem__`."
msgstr ""
msgid ""
"Note that :meth:`__missing__` is *not* called for any operations besides :"
"meth:`~object.__getitem__`. This means that :meth:`~dict.get` will, like "
"normal dictionaries, return ``None`` as a default rather than using :attr:"
"`default_factory`."
msgstr ""
msgid ":class:`defaultdict` objects support the following instance variable:"
msgstr ""
msgid ""
"This attribute is used by the :meth:`__missing__` method; it is initialized "
"from the first argument to the constructor, if present, or to ``None``, if "
"absent."
msgstr ""
msgid ""
"Added merge (``|``) and update (``|=``) operators, specified in :pep:`584`."
msgstr ""
msgid ":class:`defaultdict` Examples"
msgstr ":class:`defaultdict` Przykłady"
msgid ""
"Using :class:`list` as the :attr:`~defaultdict.default_factory`, it is easy "
"to group a sequence of key-value pairs into a dictionary of lists:"
msgstr ""
msgid ""
"When each key is encountered for the first time, it is not already in the "
"mapping; so an entry is automatically created using the :attr:`~defaultdict."
"default_factory` function which returns an empty :class:`list`. The :meth:`!"
"list.append` operation then attaches the value to the new list. When keys "
"are encountered again, the look-up proceeds normally (returning the list for "
"that key) and the :meth:`!list.append` operation adds another value to the "
"list. This technique is simpler and faster than an equivalent technique "
"using :meth:`dict.setdefault`:"
msgstr ""
msgid ""
"Setting the :attr:`~defaultdict.default_factory` to :class:`int` makes the :"
"class:`defaultdict` useful for counting (like a bag or multiset in other "
"languages):"
msgstr ""
msgid ""
"When a letter is first encountered, it is missing from the mapping, so the :"
"attr:`~defaultdict.default_factory` function calls :func:`int` to supply a "
"default count of zero. The increment operation then builds up the count for "
"each letter."
msgstr ""
msgid ""
"The function :func:`int` which always returns zero is just a special case of "
"constant functions. A faster and more flexible way to create constant "
"functions is to use a lambda function which can supply any constant value "
"(not just zero):"
msgstr ""
msgid ""
"Setting the :attr:`~defaultdict.default_factory` to :class:`set` makes the :"
"class:`defaultdict` useful for building a dictionary of sets:"
msgstr ""
msgid ":func:`namedtuple` Factory Function for Tuples with Named Fields"
msgstr ""
msgid ""
"Named tuples assign meaning to each position in a tuple and allow for more "
"readable, self-documenting code. They can be used wherever regular tuples "
"are used, and they add the ability to access fields by name instead of "
"position index."
msgstr ""
msgid ""
"Returns a new tuple subclass named *typename*. The new subclass is used to "
"create tuple-like objects that have fields accessible by attribute lookup as "
"well as being indexable and iterable. Instances of the subclass also have a "
"helpful docstring (with *typename* and *field_names*) and a helpful :meth:"
"`~object.__repr__` method which lists the tuple contents in a ``name=value`` "
"format."
msgstr ""
msgid ""
"The *field_names* are a sequence of strings such as ``['x', 'y']``. "
"Alternatively, *field_names* can be a single string with each fieldname "
"separated by whitespace and/or commas, for example ``'x y'`` or ``'x, y'``."
msgstr ""
msgid ""
"Any valid Python identifier may be used for a fieldname except for names "
"starting with an underscore. Valid identifiers consist of letters, digits, "
"and underscores but do not start with a digit or underscore and cannot be a :"
"mod:`keyword` such as *class*, *for*, *return*, *global*, *pass*, or *raise*."
msgstr ""
msgid ""
"If *rename* is true, invalid fieldnames are automatically replaced with "
"positional names. For example, ``['abc', 'def', 'ghi', 'abc']`` is "
"converted to ``['abc', '_1', 'ghi', '_3']``, eliminating the keyword ``def`` "
"and the duplicate fieldname ``abc``."
msgstr ""
msgid ""
"*defaults* can be ``None`` or an :term:`iterable` of default values. Since "
"fields with a default value must come after any fields without a default, "
"the *defaults* are applied to the rightmost parameters. For example, if the "
"fieldnames are ``['x', 'y', 'z']`` and the defaults are ``(1, 2)``, then "
"``x`` will be a required argument, ``y`` will default to ``1``, and ``z`` "
"will default to ``2``."
msgstr ""
msgid ""
"If *module* is defined, the :attr:`~type.__module__` attribute of the named "
"tuple is set to that value."
msgstr ""
msgid ""
"Named tuple instances do not have per-instance dictionaries, so they are "
"lightweight and require no more memory than regular tuples."
msgstr ""
msgid ""
"To support pickling, the named tuple class should be assigned to a variable "
"that matches *typename*."
msgstr ""
msgid "Added support for *rename*."
msgstr ""
msgid ""
"The *verbose* and *rename* parameters became :ref:`keyword-only arguments "
"<keyword-only_parameter>`."
msgstr ""
msgid "Added the *module* parameter."
msgstr ""
msgid "Removed the *verbose* parameter and the :attr:`!_source` attribute."