-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcontrolflow.po
More file actions
2723 lines (2497 loc) · 103 KB
/
Copy pathcontrolflow.po
File metadata and controls
2723 lines (2497 loc) · 103 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
# MAI MULTE UNELTE DE CONTROL AL FLUXULUI.
# Copyright (C) 2001-2025, Python Software Foundation
# This file is distributed under the same license as the Python package.
# Octavian Mustafa <octawian@yahoo.com>, 2025.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Python 3.13\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-24 07:50+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: ro\n"
"Language-Team: ro <octawian@yahoo.com>\n"
"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : (n==0 || (n%100 > 0 && n%100"
" < 20)) ? 1 : 2);\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.17.0\n"
#: ../../tutorial/controlflow.rst:5
msgid "More Control Flow Tools"
msgstr "Mai multe unelte de control al fluxului"
#: ../../tutorial/controlflow.rst:7
msgid ""
"As well as the :keyword:`while` statement just introduced, Python uses a "
"few more that we will encounter in this chapter."
msgstr ""
"Pe lângă instrucțiunea de control :keyword:`while` introdusă anterior, "
"Python-ul utilizează alte câteva asemenea instrucțiuni cu care ne vom "
"întâlni în acest capitol."
#: ../../tutorial/controlflow.rst:14
msgid ":keyword:`!if` Statements"
msgstr "Instrucțiuni :keyword:`!if`"
#: ../../tutorial/controlflow.rst:16
msgid ""
"Perhaps the most well-known statement type is the :keyword:`if` "
"statement. For example::"
msgstr ""
"Probabil că cel mai cunoscut tip de instrucțiune de control este "
"instrucțiunea :keyword:`if`. Ca, de exemplu::"
#: ../../tutorial/controlflow.rst:19
msgid ""
">>> x = int(input(\"Please enter an integer: \"))\n"
"Please enter an integer: 42\n"
">>> if x < 0:\n"
"... x = 0\n"
"... print('Negative changed to zero')\n"
"... elif x == 0:\n"
"... print('Zero')\n"
"... elif x == 1:\n"
"... print('Single')\n"
"... else:\n"
"... print('More')\n"
"...\n"
"More"
msgstr ""
">>> x = int(input(\"Vă rugăm să introduceți un număr întreg: \"))\n"
"Vă rugăm să introduceți un număr întreg: 42\n"
">>> if x < 0:\n"
"... x = 0\n"
"... print('Număr negativ, pe care îl transformăm în zero')\n"
"... elif x == 0:\n"
"... print('Numărul zero')\n"
"... elif x == 1:\n"
"... print('Numărul unu')\n"
"... else:\n"
"... print('Număr mai mare ca unu')\n"
"...\n"
"Număr mai mare ca unu"
#: ../../tutorial/controlflow.rst:33
msgid ""
"There can be zero or more :keyword:`elif` parts, and the :keyword:`else` "
"part is optional. The keyword ':keyword:`!elif`' is short for 'else if',"
" and is useful to avoid excessive indentation. An :keyword:`!if` ... "
":keyword:`!elif` ... :keyword:`!elif` ... sequence is a substitute for "
"the ``switch`` or ``case`` statements found in other languages."
msgstr ""
"Putem avea zero sau mai multe clauze :keyword:`elif`, în timp ce clauza "
":keyword:`else` este opțională. Cuvântul-cheie ':keyword:`!elif`' este "
"prescurtarea lui 'else if' și ne permite să evităm indentarea excesivă. O"
" secvență :keyword:`!if` ... :keyword:`!elif` ... :keyword:`!elif` ... "
"servește de substitut pentru instrucțiuni precum ``switch`` sau ``case`` "
"disponibile în alte limbaje de programare."
#: ../../tutorial/controlflow.rst:39
msgid ""
"If you're comparing the same value to several constants, or checking for "
"specific types or attributes, you may also find the :keyword:`!match` "
"statement useful. For more details see :ref:`tut-match`."
msgstr ""
"Dacă aveți de comparat o valoare cu mai multe constante, ori dacă "
"verificați anumite tipuri de date sau atribute, s-ar putea să vă fie "
"utilă instrucțiunea de control :keyword:`!match`. Pentru mai multe "
"detalii, vedeți :ref:`tut-match`."
#: ../../tutorial/controlflow.rst:46
msgid ":keyword:`!for` Statements"
msgstr "Instrucțiuni :keyword:`!for`"
#: ../../tutorial/controlflow.rst:51
msgid ""
"The :keyword:`for` statement in Python differs a bit from what you may be"
" used to in C or Pascal. Rather than always iterating over an arithmetic"
" progression of numbers (like in Pascal), or giving the user the ability "
"to define both the iteration step and halting condition (as C), Python's "
":keyword:`!for` statement iterates over the items of any sequence (a list"
" or a string), in the order that they appear in the sequence. For "
"example (no pun intended):"
msgstr ""
"Instrucțiunea :keyword:`for` din Python diferă puțin de cele cu care "
"poate că sunteți obișnuit din C ori din Pascal. În loc să itereze mereu "
"după elementele numerice ale unei progresii aritmetice (precum în "
"Pascal), ori să-i dea utilizatorului posibilitatea de a defini atât un "
"pas de iterație cât și o condiție de oprire (ca în C), instrucțiunea "
":keyword:`!for` a Python-ului iterează după itemii oricărei secvențe (fie"
" ea listă sau șir de caractere), în ordinea în care acești itemi apar în "
"secvență. De exemplu (fără să facem vreun `joc de cuvinte "
"<https://en.wikipedia.org/wiki/Pun>`_) :"
#: ../../tutorial/controlflow.rst:63
msgid ""
">>> # Measure some strings:\n"
">>> words = ['cat', 'window', 'defenestrate']\n"
">>> for w in words:\n"
"... print(w, len(w))\n"
"...\n"
"cat 3\n"
"window 6\n"
"defenestrate 12"
msgstr ""
">>> # Să evaluăm câteva șiruri de caractere:\n"
">>> cuvinte = ['pisică', 'fereastră', 'defenestrare']\n"
">>> for c in cuvinte:\n"
"... print(c, len(c))\n"
"...\n"
"pisică 6\n"
"fereastră 9\n"
"defenestrare 12"
#: ../../tutorial/controlflow.rst:72
msgid ""
"Code that modifies a collection while iterating over that same collection"
" can be tricky to get right. Instead, it is usually more straight-"
"forward to loop over a copy of the collection or to create a new "
"collection::"
msgstr ""
"Codul care să modifice o colecție în timp ce iterează după itemii acelei "
"colecții este greu de scris din prima încercare. În schimb, se dovedesc "
"mai ușor de realizat atât o ciclare după itemii unei copii a colecției în"
" cauză cât și crearea unei colecții noi::"
#: ../../tutorial/controlflow.rst:76
#, python-brace-format
msgid ""
"# Create a sample collection\n"
"users = {'Hans': 'active', 'Éléonore': 'inactive', '景太郎': 'active'}\n"
"\n"
"# Strategy: Iterate over a copy\n"
"for user, status in users.copy().items():\n"
" if status == 'inactive':\n"
" del users[user]\n"
"\n"
"# Strategy: Create a new collection\n"
"active_users = {}\n"
"for user, status in users.items():\n"
" if status == 'active':\n"
" active_users[user] = status"
msgstr ""
"# Crearea unei colecții eșantion\n"
"utilizatori = {'Hans': 'activ', 'Éléonore': 'inactiv', '景太郎': 'activ'}\n"
"\n"
"# Strategie: să iterăm după itemii unei copii\n"
"for utilizatorul, starea in utilizatori.copy().items():\n"
" if starea == 'inactiv':\n"
" del utilizatori[utilizatorul]\n"
"\n"
"# Strategie: să creăm o nouă colecție\n"
"utilizatori_activi = {}\n"
"for utilizatorul, starea in utilizatori.items():\n"
" if starea == 'activ':\n"
" utilizatori_activi[utilizatorul] = starea"
#: ../../tutorial/controlflow.rst:94
msgid "The :func:`range` Function"
msgstr "Funcția :func:`range`"
#: ../../tutorial/controlflow.rst:96
msgid ""
"If you do need to iterate over a sequence of numbers, the built-in "
"function :func:`range` comes in handy. It generates arithmetic "
"progressions::"
msgstr ""
"Dacă aveți de iterat după termenii unui șir de numere, atunci funcția "
"predefinită :func:`range` vă este la îndemână. Ea generează progresii "
"aritmetice::"
#: ../../tutorial/controlflow.rst:99
msgid ""
">>> for i in range(5):\n"
"... print(i)\n"
"...\n"
"0\n"
"1\n"
"2\n"
"3\n"
"4"
msgstr ""
">>> for i in range(5):\n"
"... print(i)\n"
"...\n"
"0\n"
"1\n"
"2\n"
"3\n"
"4"
#: ../../tutorial/controlflow.rst:108
msgid ""
"The given end point is never part of the generated sequence; "
"``range(10)`` generates 10 values, the legal indices for items of a "
"sequence of length 10. It is possible to let the range start at another "
"number, or to specify a different increment (even negative; sometimes "
"this is called the 'step')::"
msgstr ""
"Valoarea de final precizată nu va face niciodată parte din secvența "
"generată; ``range(10)`` generează 10 valori, mai precis indecșii permiși "
"ai itemilor unei secvențe de lungime 10. Este posibil să începem plaja de"
" valori și de la alt număr, ori să specificăm un increment diferit "
"(inclusiv negativ; uneori, el este numit 'pasul')::"
#: ../../tutorial/controlflow.rst:113
msgid ""
">>> list(range(5, 10))\n"
"[5, 6, 7, 8, 9]\n"
"\n"
">>> list(range(0, 10, 3))\n"
"[0, 3, 6, 9]\n"
"\n"
">>> list(range(-10, -100, -30))\n"
"[-10, -40, -70]"
msgstr ""
">>> list(range(5, 10))\n"
"[5, 6, 7, 8, 9]\n"
"\n"
">>> list(range(0, 10, 3))\n"
"[0, 3, 6, 9]\n"
"\n"
">>> list(range(-10, -100, -30))\n"
"[-10, -40, -70]"
#: ../../tutorial/controlflow.rst:122
msgid ""
"To iterate over the indices of a sequence, you can combine :func:`range` "
"and :func:`len` as follows::"
msgstr ""
"Pentru a itera după indicii unei secvențe, puteți combina :func:`range` "
"și :func:`len` după cum urmează. Exemplul face referire la un `cântec de "
"grădiniță american "
"<https://en.wikipedia.org/wiki/Mary_Had_a_Little_Lamb>`_::"
#: ../../tutorial/controlflow.rst:125
msgid ""
">>> a = ['Mary', 'had', 'a', 'little', 'lamb']\n"
">>> for i in range(len(a)):\n"
"... print(i, a[i])\n"
"...\n"
"0 Mary\n"
"1 had\n"
"2 a\n"
"3 little\n"
"4 lamb"
msgstr ""
">>> a = ['Maria', 'avea', 'un', 'mieluț']\n"
">>> for i in range(len(a)):\n"
"... print(i, a[i])\n"
"...\n"
"0 Maria\n"
"1 avea\n"
"2 un\n"
"3 mieluț"
#: ../../tutorial/controlflow.rst:135
msgid ""
"In most such cases, however, it is convenient to use the "
":func:`enumerate` function, see :ref:`tut-loopidioms`."
msgstr ""
"Pe de altă parte, în majoritatea unor asemenea cazuri, este convenabil să"
" utilizați funcția :func:`enumerate`, a se vedea :ref:`tut-loopidioms`."
#: ../../tutorial/controlflow.rst:138
msgid "A strange thing happens if you just print a range::"
msgstr ""
"Ceva neobișnuit se va petrece atunci când printați o plajă de valori de-a"
" dreptul::"
#: ../../tutorial/controlflow.rst:140
msgid ""
">>> range(10)\n"
"range(0, 10)"
msgstr ""
">>> range(10)\n"
"range(0, 10)"
#: ../../tutorial/controlflow.rst:143
msgid ""
"In many ways the object returned by :func:`range` behaves as if it is a "
"list, but in fact it isn't. It is an object which returns the successive "
"items of the desired sequence when you iterate over it, but it doesn't "
"really make the list, thus saving space."
msgstr ""
"În multe privințe, obiectul returnat de :func:`range` se comportă de "
"parcă ar fi o listă, însă el nu este o listă. Este doar un obiect care "
"întoarce itemii consecutivi ai secvenței care vă interesează atunci când "
"iterați după itemii acesteia, însă el nu construiește cu adevărat o listă"
" și prin aceasta economisește spațiu."
#: ../../tutorial/controlflow.rst:148
msgid ""
"We say such an object is :term:`iterable`, that is, suitable as a target "
"for functions and constructs that expect something from which they can "
"obtain successive items until the supply is exhausted. We have seen that"
" the :keyword:`for` statement is such a construct, while an example of a "
"function that takes an iterable is :func:`sum`::"
msgstr ""
"Spunem despre un asemenea obiect că este :term:`iterabil <iterable>`, "
"adică potrivit ca țintă pentru funcțiile și constructele care se așteaptă"
" la ceva din care să extragă itemi succesivi până ce rezervorul acestor "
"itemi se va goli. Am văzut deja că instrucțiunea :keyword:`for` este un "
"asemenea construct, în timp ce o funcție care poate avea un iterabil "
"drept argument este :func:`sum`::"
#: ../../tutorial/controlflow.rst:154
msgid ""
">>> sum(range(4)) # 0 + 1 + 2 + 3\n"
"6"
msgstr ""
">>> sum(range(4)) # 0 + 1 + 2 + 3\n"
"6"
#: ../../tutorial/controlflow.rst:157
msgid ""
"Later we will see more functions that return iterables and take iterables"
" as arguments. In chapter :ref:`tut-structures`, we will discuss in more"
" detail about :func:`list`."
msgstr ""
"Vom vedea ulterior și alte funcții care întorc iterabili și care primesc "
"iterabili ca argumente. În capitolul :ref:`tut-structures` vom discuta "
"mai în detaliu despre :func:`list`."
#: ../../tutorial/controlflow.rst:164
msgid ":keyword:`!break` and :keyword:`!continue` Statements"
msgstr "Instrucțiunile :keyword:`!break` și :keyword:`!continue`"
#: ../../tutorial/controlflow.rst:166
msgid ""
"The :keyword:`break` statement breaks out of the innermost enclosing "
":keyword:`for` or :keyword:`while` loop::"
msgstr ""
"Instrucțiunea :keyword:`break` stopează cea mai din interior instrucțiune"
" de ciclare :keyword:`for` sau :keyword:`while` care o include::"
#: ../../tutorial/controlflow.rst:169
#, python-brace-format, python-format
msgid ""
">>> for n in range(2, 10):\n"
"... for x in range(2, n):\n"
"... if n % x == 0:\n"
"... print(f\"{n} equals {x} * {n//x}\")\n"
"... break\n"
"...\n"
"4 equals 2 * 2\n"
"6 equals 2 * 3\n"
"8 equals 2 * 4\n"
"9 equals 3 * 3"
msgstr ""
">>> for n in range(2, 10):\n"
"... for x in range(2, n):\n"
"... if n % x == 0:\n"
"... print(f\"{n} este egal cu {x} * {n//x}\")\n"
"... break\n"
"...\n"
"4 este egal cu 2 * 2\n"
"6 este egal cu 2 * 3\n"
"8 este egal cu 2 * 4\n"
"9 este egal cu 3 * 3"
#: ../../tutorial/controlflow.rst:180
msgid ""
"The :keyword:`continue` statement continues with the next iteration of "
"the loop::"
msgstr ""
"Instrucțiunea :keyword:`continue` trece la următoarea iterație a "
"ciclului::"
#: ../../tutorial/controlflow.rst:183
#, python-brace-format
msgid ""
">>> for num in range(2, 10):\n"
"... if num % 2 == 0:\n"
"... print(f\"Found an even number {num}\")\n"
"... continue\n"
"... print(f\"Found an odd number {num}\")\n"
"...\n"
"Found an even number 2\n"
"Found an odd number 3\n"
"Found an even number 4\n"
"Found an odd number 5\n"
"Found an even number 6\n"
"Found an odd number 7\n"
"Found an even number 8\n"
"Found an odd number 9"
msgstr ""
">>> for num in range(2, 10):\n"
"... if num % 2 == 0:\n"
"... print(f\"Găsit un număr par {num}\")\n"
"... continue\n"
"... print(f\"Găsit un număr impar {num}\")\n"
"...\n"
"Găsit un număr par 2\n"
"Găsit un număr impar 3\n"
"Găsit un număr par 4\n"
"Găsit un număr impar 5\n"
"Găsit un număr par 6\n"
"Găsit un număr impar 7\n"
"Găsit un număr par 8\n"
"Găsit un număr impar 9"
#: ../../tutorial/controlflow.rst:202
msgid ":keyword:`!else` Clauses on Loops"
msgstr "Clauzele :keyword:`!else` ale ciclurilor"
#: ../../tutorial/controlflow.rst:204
msgid ""
"In a :keyword:`!for` or :keyword:`!while` loop the :keyword:`!break` "
"statement may be paired with an :keyword:`!else` clause. If the loop "
"finishes without executing the :keyword:`!break`, the :keyword:`!else` "
"clause executes."
msgstr ""
"Într-un ciclu :keyword:`!for` sau :keyword:`!while`, instrucțiunea "
":keyword:`!break` poate fi utilizată în tandem cu clauza "
":keyword:`!else`. Astfel, dacă ciclul se încheie fără să fi fost executat"
" :keyword:`!break`-ul, atunci va fi executată clauza :keyword:`!else`."
#: ../../tutorial/controlflow.rst:208
msgid ""
"In a :keyword:`for` loop, the :keyword:`!else` clause is executed after "
"the loop finishes its final iteration, that is, if no break occurred."
msgstr ""
"Într-un ciclu :keyword:`for`, clauza :keyword:`!else` se execută după ce "
"bucla își încheie iterația finală, adică dacă nu a intervenit nicio "
"stopare pe parcurs."
#: ../../tutorial/controlflow.rst:211
msgid ""
"In a :keyword:`while` loop, it's executed after the loop's condition "
"becomes false."
msgstr ""
"Într-un ciclu :keyword:`while`, clauza se va executa după ce condiția "
"buclei va deveni falsă."
#: ../../tutorial/controlflow.rst:213
msgid ""
"In either kind of loop, the :keyword:`!else` clause is **not** executed "
"if the loop was terminated by a :keyword:`break`. Of course, other ways "
"of ending the loop early, such as a :keyword:`return` or a raised "
"exception, will also skip execution of the :keyword:`else` clause."
msgstr ""
"Pentru ambele tipuri de ciclare, clauza :keyword:`!else` **nu** se va "
"executa dacă ciclul în cauză s-a terminat cu un :keyword:`break`. "
"Desigur, și alte cazuri de oprire timpurie a ciclării, precum un "
":keyword:`return` sau lansarea (de la englezescul *to raise*) unei "
"excepții, vor anula execuția clauzei :keyword:`else`."
#: ../../tutorial/controlflow.rst:218
msgid ""
"This is exemplified in the following :keyword:`!for` loop, which searches"
" for prime numbers::"
msgstr ""
"Toate acestea se exemplifică în următorul ciclu :keyword:`!for`, cu care"
" căutăm numere prime::"
#: ../../tutorial/controlflow.rst:221
#, python-format
msgid ""
">>> for n in range(2, 10):\n"
"... for x in range(2, n):\n"
"... if n % x == 0:\n"
"... print(n, 'equals', x, '*', n//x)\n"
"... break\n"
"... else:\n"
"... # loop fell through without finding a factor\n"
"... print(n, 'is a prime number')\n"
"...\n"
"2 is a prime number\n"
"3 is a prime number\n"
"4 equals 2 * 2\n"
"5 is a prime number\n"
"6 equals 2 * 3\n"
"7 is a prime number\n"
"8 equals 2 * 4\n"
"9 equals 3 * 3"
msgstr ""
">>> for n in range(2, 10):\n"
"... for x in range(2, n):\n"
"... if n % x == 0:\n"
"... print(n, 'este egal cu', x, '*', n//x)\n"
"... break\n"
"... else:\n"
"... # cade până aici fără să fi găsit vreun divizor\n"
"... print(n, 'este număr prim')\n"
"...\n"
"2 este număr prim\n"
"3 este număr prim\n"
"4 este egal cu 2 * 2\n"
"5 este număr prim\n"
"6 este egal cu 2 * 3\n"
"7 este număr prim\n"
"8 este egal cu 2 * 4\n"
"9 este egal cu 3 * 3"
#: ../../tutorial/controlflow.rst:239
msgid ""
"(Yes, this is the correct code. Look closely: the ``else`` clause "
"belongs to the ``for`` loop, **not** the ``if`` statement.)"
msgstr ""
"(Da, acesta este codul corect. Uitați-vă îndeaproape: clauza ``else`` "
"ține de bucla ``for`` și **nu** de instrucțiunea ``if``.)"
#: ../../tutorial/controlflow.rst:242
msgid ""
"One way to think of the else clause is to imagine it paired with the "
"``if`` inside the loop. As the loop executes, it will run a sequence "
"like if/if/if/else. The ``if`` is inside the loop, encountered a number "
"of times. If the condition is ever true, a ``break`` will happen. If the "
"condition is never true, the ``else`` clause outside the loop will "
"execute."
msgstr ""
"Este bine, atunci când vă gândiți la clauza else, să o socotiți ca făcând"
" pereche cu ``if``-ul din buclă. Pe măsură ce bucla este executată, ea va"
" rula o secvență de tipul if/if/if/else. Acest ``if`` este în interiorul "
"buclei și va fi întâlnit de un număr oarecare de ori. Dacă condiția "
"asociată lui va avea valoarea logică adevărat la un moment dat, atunci se"
" va produce un ``break``. În schimb, dacă valoarea logică a condiției nu "
"va fi niciodată adevărat, atunci se va executa clauza ``else`` din afara "
"buclei."
#: ../../tutorial/controlflow.rst:248
msgid ""
"When used with a loop, the ``else`` clause has more in common with the "
"``else`` clause of a :keyword:`try` statement than it does with that of "
"``if`` statements: a ``try`` statement's ``else`` clause runs when no "
"exception occurs, and a loop's ``else`` clause runs when no ``break`` "
"occurs. For more on the ``try`` statement and exceptions, see :ref:`tut-"
"handling`."
msgstr ""
"Atunci când este folosită cu o instrucțiune de ciclare, clauza ``else`` "
"seamănă mai degrabă cu clauza ``else`` a unei instrucțiuni :keyword:`try`"
" decât cu cea a unor instrucțiuni ``if``: clauza ``else`` a unei "
"instrucțiuni ``try`` va rula numai atunci când nu survine nicio excepție,"
" pe când clauza ``else`` a unei bucle va rula atunci când nu intervine "
"niciun ``break``. Pentru detalii privind instrucțiunea ``try`` și "
"excepțiile, vedeți :ref:`tut-handling`."
#: ../../tutorial/controlflow.rst:258
msgid ":keyword:`!pass` Statements"
msgstr "Instrucțiuni :keyword:`!pass`"
#: ../../tutorial/controlflow.rst:260
msgid ""
"The :keyword:`pass` statement does nothing. It can be used when a "
"statement is required syntactically but the program requires no action. "
"For example::"
msgstr ""
"Instrucțiunea :keyword:`pass` nu realizează nimic. Ea poate fi folosită "
"atunci când sintaxa limbajului cere introducerea unei instrucțiuni dar "
"programul propriu-zis nu are nimic de executat. De exemplu::"
#: ../../tutorial/controlflow.rst:263
msgid ""
">>> while True:\n"
"... pass # Busy-wait for keyboard interrupt (Ctrl+C)\n"
"..."
msgstr ""
">>> while True:\n"
"... pass # Ocupat-se așteaptă o întrerupere de la tastatură (Ctrl+C)"
"\n"
"..."
#: ../../tutorial/controlflow.rst:267
msgid "This is commonly used for creating minimal classes::"
msgstr "Se folosește în mod uzual la crearea unor clase minimale::"
#: ../../tutorial/controlflow.rst:269
msgid ""
">>> class MyEmptyClass:\n"
"... pass\n"
"..."
msgstr ""
">>> class ClasaMeaVidă:\n"
"... pass\n"
"..."
#: ../../tutorial/controlflow.rst:273
msgid ""
"Another place :keyword:`pass` can be used is as a place-holder for a "
"function or conditional body when you are working on new code, allowing "
"you to keep thinking at a more abstract level. The :keyword:`!pass` is "
"silently ignored::"
msgstr ""
"Altă întrebuințare pentru :keyword:`pass` este ca înlocuitor al corpului "
"unei funcții sau al celui al unei instrucțiuni de selecție atunci când "
"lucrați la un program nou, permițându-vă să gândiți programul la nivel "
"abstract. Instrucțiunea :keyword:`!pass` este ignorată în mod silențios::"
#: ../../tutorial/controlflow.rst:277
msgid ""
">>> def initlog(*args):\n"
"... pass # Remember to implement this!\n"
"..."
msgstr ""
">>> def initlog(*args):\n"
"... pass # Nu uitați să o implementați!\n"
"..."
#: ../../tutorial/controlflow.rst:281
msgid ""
"For this last case, many people use the ellipsis literal :code:`...` "
"instead of :code:`pass`. This use has no special meaning to Python, and "
"is not part of the language definition (you could use any constant "
"expression here), but :code:`...` is used conventionally as a placeholder"
" body as well. See :ref:`bltin-ellipsis-object`."
msgstr ""
"În acest din urmă caz, mulți programatori utilizează literalul *elipsă*, "
":code:`...`, în locul lui :code:`pass`. Acest literal nu dispune de nicio "
"semnificație aparte în Python și nici nu se regăsește în definiția "
"limbajului (puteți folosi orice expresie constantă în locul său), doar că "
":code:`...` se întrebuințează în mod convențional drept înlocuitorul unui "
"corp de funcție. Vedeți :ref:`bltin-ellipsis-object`."
#: ../../tutorial/controlflow.rst:291
msgid ":keyword:`!match` Statements"
msgstr "Instrucțiuni :keyword:`!match`"
#: ../../tutorial/controlflow.rst:293
msgid ""
"A :keyword:`match` statement takes an expression and compares its value "
"to successive patterns given as one or more case blocks. This is "
"superficially similar to a switch statement in C, Java or JavaScript (and"
" many other languages), but it's more similar to pattern matching in "
"languages like Rust or Haskell. Only the first pattern that matches gets "
"executed and it can also extract components (sequence elements or object "
"attributes) from the value into variables."
msgstr ""
"O instrucțiune :keyword:`match` preia o expresie și îi compară valoarea "
"cu modelele date de blocuri case de cod succesive. Aceasta o face să "
"semene, la prima vedere, cu o instrucțiune switch din C, Java sau "
"JavaScript (și din multe alte limbaje), doar că ea este mai degrabă "
"similară cu potrivirea după model (de la englezescul *pattern matching*) "
"din limbaje precum Rust ori Haskell. Va fi executat numai primul model "
"care se potrivește și tot atunci vor putea fi salvate în variabile "
"diverse componente (cum ar fi itemi de secvență ori atribute de obiect) "
"ale valorii expresiei."
#: ../../tutorial/controlflow.rst:301
msgid "The simplest form compares a subject value against one or more literals::"
msgstr ""
"În cea mai simplă formă, ea compară valoarea unei mărimi cu valorile "
"uneia sau mai multor date literale. În exemplul care urmează este "
"introdus un cod de răspuns HTTP (418) folosit ca `păcăleală de întâi "
"aprilie <https://developer.mozilla.org/en-"
"US/docs/Web/HTTP/Reference/Status/418>`_::"
#: ../../tutorial/controlflow.rst:303
msgid ""
"def http_error(status):\n"
" match status:\n"
" case 400:\n"
" return \"Bad request\"\n"
" case 404:\n"
" return \"Not found\"\n"
" case 418:\n"
" return \"I'm a teapot\"\n"
" case _:\n"
" return \"Something's wrong with the internet\""
msgstr ""
"def http_error(stare):\n"
" match stare:\n"
" case 400:\n"
" return \"Cerere incorectă\"\n"
" case 404:\n"
" return \"Nu a fost găsită\"\n"
" case 418:\n"
" return \"Eu sunt un ceainic\"\n"
" case _:\n"
" return \"S-a întâmplat ceva cu conexiunea internet\""
#: ../../tutorial/controlflow.rst:314
msgid ""
"Note the last block: the \"variable name\" ``_`` acts as a *wildcard* and"
" never fails to match. If no case matches, none of the branches is "
"executed."
msgstr ""
"Observați ultimul bloc: \"numele de variabilă\" ``_`` acționează ca un "
"*caracter de înlocuire* (de la englezescul *wildcard*) care se va potrivi"
" cu toate valorile. Dacă niciunul dintre case-uri nu se potrivește, "
"niciuna din ramurile de cod nu se va executa."
#: ../../tutorial/controlflow.rst:317
msgid ""
"You can combine several literals in a single pattern using ``|`` "
"(\"or\")::"
msgstr ""
"Puteți combina mai mulți literali într-un singur model folosind ``|`` "
"(\"sau\")::"
#: ../../tutorial/controlflow.rst:319
msgid ""
"case 401 | 403 | 404:\n"
" return \"Not allowed\""
msgstr ""
"case 401 | 403 | 404:\n"
" return \"Nepermis\""
#: ../../tutorial/controlflow.rst:322
msgid ""
"Patterns can look like unpacking assignments, and can be used to bind "
"variables::"
msgstr ""
"Modelele pot semăna cu atribuirile cu despachetare (de la englezescul "
"*unpacking assignment*), putând fi folosite la legarea variabilelor::"
#: ../../tutorial/controlflow.rst:325
#, python-brace-format
msgid ""
"# point is an (x, y) tuple\n"
"match point:\n"
" case (0, 0):\n"
" print(\"Origin\")\n"
" case (0, y):\n"
" print(f\"Y={y}\")\n"
" case (x, 0):\n"
" print(f\"X={x}\")\n"
" case (x, y):\n"
" print(f\"X={x}, Y={y}\")\n"
" case _:\n"
" raise ValueError(\"Not a point\")"
msgstr ""
"# punctul este un tuplu (x, y)\n"
"match punctul:\n"
" case (0, 0):\n"
" print(\"Originea\")\n"
" case (0, y):\n"
" print(f\"Y={y}\")\n"
" case (x, 0):\n"
" print(f\"X={x}\")\n"
" case (x, y):\n"
" print(f\"X={x}, Y={y}\")\n"
" case _:\n"
" raise ValueError(\"Nu este punct\")"
#: ../../tutorial/controlflow.rst:338
msgid ""
"Study that one carefully! The first pattern has two literals, and can be"
" thought of as an extension of the literal pattern shown above. But the "
"next two patterns combine a literal and a variable, and the variable "
"*binds* a value from the subject (``point``). The fourth pattern "
"captures two values, which makes it conceptually similar to the unpacking"
" assignment ``(x, y) = point``."
msgstr ""
"Studiați exemplul cu atenție! Primul model are doi literali, și poate fi "
"considerat ca o extensie a modelului literal prezentat înainte. "
"Următoarele două modele, în schimb, combină o dată literală cu o "
"variabilă, iar de variabilă se *leagă* o valoare din mărime "
"(``punctul``). Cel de-al patrulea model captează două valori, ceea ce îl "
"face conceptual echivalent atribuirii cu despachetare ``(x, y) = "
"punctul``."
#: ../../tutorial/controlflow.rst:345
msgid ""
"If you are using classes to structure your data you can use the class "
"name followed by an argument list resembling a constructor, but with the "
"ability to capture attributes into variables::"
msgstr ""
"Dacă folosiți clase pentru a vă structura datele în program, atunci veți "
"putea utiliza numele clasei urmat de o listă de argumente asemănătoare "
"celei a unui constructor, doar că având proprietatea de a salva atribute "
"în variabile::"
#: ../../tutorial/controlflow.rst:349
#, python-brace-format
msgid ""
"class Point:\n"
" def __init__(self, x, y):\n"
" self.x = x\n"
" self.y = y\n"
"\n"
"def where_is(point):\n"
" match point:\n"
" case Point(x=0, y=0):\n"
" print(\"Origin\")\n"
" case Point(x=0, y=y):\n"
" print(f\"Y={y}\")\n"
" case Point(x=x, y=0):\n"
" print(f\"X={x}\")\n"
" case Point():\n"
" print(\"Somewhere else\")\n"
" case _:\n"
" print(\"Not a point\")"
msgstr ""
"class Punctul:\n"
" def __init__(self, x, y):\n"
" self.x = x\n"
" self.y = y\n"
"\n"
"def unde_este(punctul):\n"
" match punctul:\n"
" case Punctul(x=0, y=0):\n"
" print(\"Originea\")\n"
" case Punctul(x=0, y=y):\n"
" print(f\"Y={y}\")\n"
" case Punctul(x=x, y=0):\n"
" print(f\"X={x}\")\n"
" case Punctul():\n"
" print(\"Altundeva\")\n"
" case _:\n"
" print(\"Nu e punct\")"
#: ../../tutorial/controlflow.rst:367
msgid ""
"You can use positional parameters with some builtin classes that provide "
"an ordering for their attributes (e.g. dataclasses). You can also define "
"a specific position for attributes in patterns by setting the "
"``__match_args__`` special attribute in your classes. If it's set to "
"(\"x\", \"y\"), the following patterns are all equivalent (and all bind "
"the ``y`` attribute to the ``var`` variable)::"
msgstr ""
"Puteți utiliza argumente poziționale la unele din clasele predefinite, "
"cele care oferă o ordonare a atributelor lor (precum clasele-de-date). De"
" asemenea, puteți defini poziții specifice pentru atributele din modele "
"prin setarea atributului special ``__match_args__`` pentru clasele "
"dumneavoastră. Dacă acesta este setat la (\"x\", \"y\"), atunci "
"următoarele modele sunt cu toatele echivalente (și toate leagă atributul "
"``y`` de variabila ``var``)::"
#: ../../tutorial/controlflow.rst:373
msgid ""
"Point(1, var)\n"
"Point(1, y=var)\n"
"Point(x=1, y=var)\n"
"Point(y=var, x=1)"
msgstr ""
"Punctul(1, var)\n"
"Punctul(1, y=var)\n"
"Punctul(x=1, y=var)\n"
"Punctul(y=var, x=1)"
#: ../../tutorial/controlflow.rst:378
msgid ""
"A recommended way to read patterns is to look at them as an extended form"
" of what you would put on the left of an assignment, to understand which "
"variables would be set to what. Only the standalone names (like ``var`` "
"above) are assigned to by a match statement. Dotted names (like "
"``foo.bar``), attribute names (the ``x=`` and ``y=`` above) or class "
"names (recognized by the \"(...)\" next to them like ``Point`` above) are"
" never assigned to."
msgstr ""
"Atunci când citim un model este recomandat să-l privim ca pe forma "
"extinsă a ceea ce se pune la stânga unei atribuiri, respectiv să "
"înțelegem ce variabilă va fi setată la ce valoare. O instrucțiune match "
"poate face atribuiri numai pentru numele de sine stătătoare (precum "
"``var``-ul de deasupra). Numelor-cu-punct (de la englezescul *dotted "
"name*; ca, de exemplu, ``foo.bar``, o expresie intraductibilă, vedeți "
"`foobar <https://en.wikipedia.org/wiki/Foobar>`_), numelor de atribute "
"(``x=`` și ``y=`` de mai sus) ori numelor de clase (pe care le "
"recunoaștem după \"(...)\"-ul așezat după ele, ca în cazul lui "
"``Punctul`` de deasupra) nu li se fac niciodată atribuiri."
#: ../../tutorial/controlflow.rst:385
msgid ""
"Patterns can be arbitrarily nested. For example, if we have a short list"
" of Points, with ``__match_args__`` added, we could match it like this::"
msgstr ""
"Modelele pot fi imbricate de câte ori dorim. De exemplu, dacă avem o "
"listă scurtă de Puncte, căreia i-am adăugat ``__match_args__``, îi putem "
"aplica un match astfel::"
#: ../../tutorial/controlflow.rst:388
#, python-brace-format
msgid ""
"class Point:\n"
" __match_args__ = ('x', 'y')\n"
" def __init__(self, x, y):\n"
" self.x = x\n"
" self.y = y\n"
"\n"
"match points:\n"
" case []:\n"
" print(\"No points\")\n"
" case [Point(0, 0)]:\n"
" print(\"The origin\")\n"
" case [Point(x, y)]:\n"
" print(f\"Single point {x}, {y}\")\n"
" case [Point(0, y1), Point(0, y2)]:\n"
" print(f\"Two on the Y axis at {y1}, {y2}\")\n"
" case _:\n"
" print(\"Something else\")"
msgstr ""
"class Punctul:\n"
" __match_args__ = ('x', 'y')\n"
" def __init__(self, x, y):\n"
" self.x = x\n"
" self.y = y\n"
"\n"
"match puncte:\n"
" case []:\n"
" print(\"Niciun punct\")\n"
" case [Punctul(0, 0)]:\n"
" print(\"Originea\")\n"
" case [Punctul(x, y)]:\n"
" print(f\"Un singur punct {x}, {y}\")\n"
" case [Punctul(0, y1), Punctul(0, y2)]:\n"
" print(f\"Două puncte pe axa Y la {y1}, {y2}\")\n"
" case _:\n"
" print(\"Altceva\")"
#: ../../tutorial/controlflow.rst:406
msgid ""
"We can add an ``if`` clause to a pattern, known as a \"guard\". If the "
"guard is false, ``match`` goes on to try the next case block. Note that "
"value capture happens before the guard is evaluated::"
msgstr ""
"Îi putem adăuga o clauză ``if``, numită \"gardă\" (de la englezescul "
"*guard*), unui model. Dacă valoarea logică a gărzii este fals, atunci "
"``match``-ul trece la următorul bloc case. Captarea valorilor, trebuie "
"remarcat, se va petrece înainte de evaluarea gărzii::"
#: ../../tutorial/controlflow.rst:410
#, python-brace-format
msgid ""
"match point:\n"
" case Point(x, y) if x == y:\n"
" print(f\"Y=X at {x}\")\n"
" case Point(x, y):\n"
" print(f\"Not on the diagonal\")"
msgstr ""
"match punct:\n"
" case Punctul(x, y) if x == y:\n"
" print(f\"Y=X la {x}\")\n"
" case Punctul(x, y):\n"
" print(f\"Nu e pe diagonală\")"
#: ../../tutorial/controlflow.rst:416
msgid "Several other key features of this statement:"
msgstr "Alte caracteristici-cheie ale acestei instrucțiuni:"
#: ../../tutorial/controlflow.rst:418
msgid ""
"Like unpacking assignments, tuple and list patterns have exactly the same"
" meaning and actually match arbitrary sequences. An important exception "
"is that they don't match iterators or strings."
msgstr ""
"În calitate de atribuiri cu despachetare, tuplurile și modelele de liste "
"au aceeași semnificație și reușesc să se potrivească unor secvențe "
"arbitrare. O excepție importantă este aceea că ele nu fac potriviri "
"pentru iteratori sau șiruri de caractere."
#: ../../tutorial/controlflow.rst:422
msgid ""
"Sequence patterns support extended unpacking: ``[x, y, *rest]`` and ``(x,"
" y, *rest)`` work similar to unpacking assignments. The name after ``*``"
" may also be ``_``, so ``(x, y, *_)`` matches a sequence of at least two "
"items without binding the remaining items."
msgstr ""
"Modelele de secvențe suportă despachetări extinse: ``[x, y, *restul]`` și"
" ``(x, y, *restul)`` se comportă similar cu atribuirile cu despachetare. "
"Numele de după ``*`` poate fi inclusiv ``_``, astfel că ``(x, y, *_)`` se"
" va potrivi unei secvențe de cel puțin doi itemi fără a mai lega itemii "
"rămași."
#: ../../tutorial/controlflow.rst:427
#, python-brace-format
msgid ""
"Mapping patterns: ``{\"bandwidth\": b, \"latency\": l}`` captures the "
"``\"bandwidth\"`` and ``\"latency\"`` values from a dictionary. Unlike "
"sequence patterns, extra keys are ignored. An unpacking like ``**rest`` "
"is also supported. (But ``**_`` would be redundant, so it is not "
"allowed.)"
msgstr ""
"Modele de mapare: ``{\"lățime_de_bandă\": b, \"latență\": l}`` capturează"
" valorile lui ``\"lățime_de_bandă\"`` și ``\"latență\"`` dintr-un "
"dicționar. Spre deosebire de cazul modelelor de secvențe, cheile "
"suplimentare vor fi ignorate. Este suportată și o despachetare de tipul "