@@ -573,6 +573,8 @@ msgid ""
573
573
"Batch data from the *iterable* into tuples of length *n*. The last batch may "
574
574
"be shorter than *n*."
575
575
msgstr ""
576
+ "Dados de lote do *iterable* em tuplas de comprimento *n*. O último lote pode "
577
+ "ser menor que *n*."
576
578
577
579
#: ../../library/itertools.rst:170
578
580
msgid ""
@@ -581,6 +583,10 @@ msgid ""
581
583
"is yielded as soon as the batch is full or when the input iterable is "
582
584
"exhausted:"
583
585
msgstr ""
586
+ "Faz um laço sobre o iterável de entrada e acumula dados em tuplas de até o "
587
+ "tamanho *n*. A entrada é consumida preguiçosamente, apenas o suficiente para "
588
+ "preencher um lote. O resultado é produzido assim que o lote estiver cheio ou "
589
+ "quando o iterável de entrada estiver esgotado:"
584
590
585
591
#: ../../library/itertools.rst:175
586
592
msgid ""
@@ -589,6 +595,10 @@ msgid ""
589
595
">>> unflattened\n"
590
596
"[('roses', 'red'), ('violets', 'blue'), ('sugar', 'sweet')]"
591
597
msgstr ""
598
+ ">>> flattened_data = ['roses', 'red', 'violets', 'blue', 'sugar', 'sweet']\n"
599
+ ">>> unflattened = list(batched(flattened_data, 2))\n"
600
+ ">>> unflattened\n"
601
+ "[('roses', 'red'), ('violets', 'blue'), ('sugar', 'sweet')]"
592
602
593
603
#: ../../library/itertools.rst:184
594
604
msgid ""
@@ -620,6 +630,10 @@ msgid ""
620
630
" for iterable in iterables:\n"
621
631
" yield from iterable"
622
632
msgstr ""
633
+ "def chain(*iterables):\n"
634
+ " # chain('ABC', 'DEF') → A B C D E F\n"
635
+ " for iterable in iterables:\n"
636
+ " yield from iterable"
623
637
624
638
#: ../../library/itertools.rst:210
625
639
msgid ""
@@ -637,6 +651,10 @@ msgid ""
637
651
" for iterable in iterables:\n"
638
652
" yield from iterable"
639
653
msgstr ""
654
+ "def from_iterable(iterables):\n"
655
+ " # chain.from_iterable(['ABC', 'DEF']) → A B C D E F\n"
656
+ " for iterable in iterables:\n"
657
+ " yield from iterable"
640
658
641
659
#: ../../library/itertools.rst:221
642
660
msgid "Return *r* length subsequences of elements from the input *iterable*."
@@ -651,20 +669,30 @@ msgid ""
651
669
"`math.comb` which computes ``n! / r! / (n - r)!`` when ``0 ≤ r ≤ n`` or zero "
652
670
"when ``r > n``."
653
671
msgstr ""
672
+ "A saída é uma subsequência de :func:`product` mantendo apenas entradas que "
673
+ "são subsequências do *iterable*. O comprimento da saída é dado por :func:"
674
+ "`math.comb` que calcula ``n! / r! / (n - r)!`` quando ``0 ≤ r ≤ n`` ou zero "
675
+ "quando ``r > n``."
654
676
655
677
#: ../../library/itertools.rst:228
656
678
msgid ""
657
679
"The combination tuples are emitted in lexicographic order according to the "
658
680
"order of the input *iterable*. If the input *iterable* is sorted, the output "
659
681
"tuples will be produced in sorted order."
660
682
msgstr ""
683
+ "As tuplas das combinações são emitidas em ordem lexicográfica de acordo com "
684
+ "a ordem do iterável de entrada. Se o iterável estiver ordenado, as tuplas de "
685
+ "combinação serão produzidas em sequência ordenada."
661
686
662
687
#: ../../library/itertools.rst:232
663
688
msgid ""
664
689
"Elements are treated as unique based on their position, not on their value. "
665
690
"If the input elements are unique, there will be no repeated values within "
666
691
"each combination."
667
692
msgstr ""
693
+ "Os elementos são tratados como únicos baseado em suas posições, não em seus "
694
+ "valores. Se os elementos de entrada são únicos, não haverá repetição de "
695
+ "valores nas sucessivas combinações."
668
696
669
697
#: ../../library/itertools.rst:238
670
698
msgid ""
@@ -690,6 +718,27 @@ msgid ""
690
718
" indices[j] = indices[j-1] + 1\n"
691
719
" yield tuple(pool[i] for i in indices)"
692
720
msgstr ""
721
+ "def combinations(iterable, r):\n"
722
+ " # combinations('ABCD', 2) → AB AC AD BC BD CD\n"
723
+ " # combinations(range(4), 3) → 012 013 023 123\n"
724
+ "\n"
725
+ " pool = tuple(iterable)\n"
726
+ " n = len(pool)\n"
727
+ " if r > n:\n"
728
+ " return\n"
729
+ " indices = list(range(r))\n"
730
+ "\n"
731
+ " yield tuple(pool[i] for i in indices)\n"
732
+ " while True:\n"
733
+ " for i in reversed(range(r)):\n"
734
+ " if indices[i] != i + n - r:\n"
735
+ " break\n"
736
+ " else:\n"
737
+ " return\n"
738
+ " indices[i] += 1\n"
739
+ " for j in range(i+1, r):\n"
740
+ " indices[j] = indices[j-1] + 1\n"
741
+ " yield tuple(pool[i] for i in indices)"
693
742
694
743
#: ../../library/itertools.rst:263
695
744
msgid ""
@@ -706,20 +755,30 @@ msgid ""
706
755
"number of subsequence returned is ``(n + r - 1)! / r! / (n - 1)!`` when ``n "
707
756
"> 0``."
708
757
msgstr ""
758
+ "A saída é uma subsequência de :func:`product` que mantém apenas entradas que "
759
+ "são subsequências (com possíveis elementos repetidos) do *iterable*. O "
760
+ "número de subsequências retornadas é ``(n + r - 1)! / r! / (n - 1)!`` quando "
761
+ "``n > 0``."
709
762
710
763
#: ../../library/itertools.rst:271
711
764
msgid ""
712
765
"The combination tuples are emitted in lexicographic order according to the "
713
766
"order of the input *iterable*. if the input *iterable* is sorted, the output "
714
767
"tuples will be produced in sorted order."
715
768
msgstr ""
769
+ "As tuplas das combinações são emitidas em ordem lexicográfica de acordo com "
770
+ "a ordem do iterável de entrada. Se o iterável estiver ordenado, as tuplas de "
771
+ "combinação serão produzidas em sequência ordenada."
716
772
717
773
#: ../../library/itertools.rst:275
718
774
msgid ""
719
775
"Elements are treated as unique based on their position, not on their value. "
720
776
"If the input elements are unique, the generated combinations will also be "
721
777
"unique."
722
778
msgstr ""
779
+ "Os elementos são tratados como únicos baseado em suas posições, não em seus "
780
+ "valores. Se os elementos de entrada forem únicos, não haverá repetição de "
781
+ "valores nas combinações geradas."
723
782
724
783
#: ../../library/itertools.rst:281
725
784
msgid ""
@@ -742,27 +801,55 @@ msgid ""
742
801
" indices[i:] = [indices[i] + 1] * (r - i)\n"
743
802
" yield tuple(pool[i] for i in indices)"
744
803
msgstr ""
804
+ "def combinations_with_replacement(iterable, r):\n"
805
+ " # combinations_with_replacement('ABC', 2) → AA AB AC BB BC CC\n"
806
+ "\n"
807
+ " pool = tuple(iterable)\n"
808
+ " n = len(pool)\n"
809
+ " if not n and r:\n"
810
+ " return\n"
811
+ " indices = [0] * r\n"
812
+ "\n"
813
+ " yield tuple(pool[i] for i in indices)\n"
814
+ " while True:\n"
815
+ " for i in reversed(range(r)):\n"
816
+ " if indices[i] != n - 1:\n"
817
+ " break\n"
818
+ " else:\n"
819
+ " return\n"
820
+ " indices[i:] = [indices[i] + 1] * (r - i)\n"
821
+ " yield tuple(pool[i] for i in indices)"
745
822
746
823
#: ../../library/itertools.rst:305
747
824
msgid ""
748
825
"Make an iterator that returns elements from *data* where the corresponding "
749
826
"element in *selectors* is true. Stops when either the *data* or *selectors* "
750
827
"iterables have been exhausted. Roughly equivalent to::"
751
828
msgstr ""
829
+ "Cria um iterador que retorne elementos de *data* onde o elemento "
830
+ "correspondente em *selectors* é verdadeiro. Para quando os iteráveis *data* "
831
+ "ou *selectors* forem esgotados. Aproximadamente equivalente a::"
752
832
753
833
#: ../../library/itertools.rst:310
754
834
msgid ""
755
835
"def compress(data, selectors):\n"
756
836
" # compress('ABCDEF', [1,0,1,0,1,1]) → A C E F\n"
757
837
" return (datum for datum, selector in zip(data, selectors) if selector)"
758
838
msgstr ""
839
+ "def compress(data, selectors):\n"
840
+ " # compress('ABCDEF', [1,0,1,0,1,1]) → A C E F\n"
841
+ " return (datum for datum, selector in zip(data, selectors) if selector)"
759
842
760
843
#: ../../library/itertools.rst:319
761
844
msgid ""
762
845
"Make an iterator that returns evenly spaced values beginning with *start*. "
763
846
"Can be used with :func:`map` to generate consecutive data points or with :"
764
847
"func:`zip` to add sequence numbers. Roughly equivalent to::"
765
848
msgstr ""
849
+ "Cria um iterador que retorne valores uniformemente espaçados começando com "
850
+ "*start*. Pode ser usado com :func:`map` para gerar pontos de dados "
851
+ "consecutivos ou com :func:`zip` para adicionar números de sequência. "
852
+ "Aproximadamente equivalente a::"
766
853
767
854
#: ../../library/itertools.rst:324
768
855
msgid ""
@@ -774,6 +861,13 @@ msgid ""
774
861
" yield n\n"
775
862
" n += step"
776
863
msgstr ""
864
+ "def count(start=0, step=1):\n"
865
+ " # count(10) → 10 11 12 13 14 ...\n"
866
+ " # count(2.5, 0.5) → 2.5 3.0 3.5 ...\n"
867
+ " n = start\n"
868
+ " while True:\n"
869
+ " yield n\n"
870
+ " n += step"
777
871
778
872
#: ../../library/itertools.rst:332
779
873
msgid ""
0 commit comments