GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — python-docs-pa/tutorial/classes.po at 3.15 · python/python-docs-pa Expand file tree/ Copy pathclasses.poMore file actions 1825 lines (1671 loc) · 116 KB / Copy pathclasses.poFile metadata and controls1825 lines (1671 loc) · 116 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 # SOME DESCRIPTIVE TITLE. # Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. # # Translators: # Bhuvansh Kataria, 2026 # #, fuzzy msgid "" msgstr "" "Project-Id-Version: Python 3.15\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2026-11-05 20:53+0000\n" "PO-Revision-Date: 2025-09-16 00:02+0000\n" "Last-Translator: Bhuvansh Kataria, 2026\n" "Language-Team: Panjabi (Punjabi) (https://app.transifex.com/python-doc/teams/" "5390/pa/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: pa\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" msgid "Classes" msgstr "ਕਲਾਸਾਂ" msgid "" "Classes provide a means of bundling data and functionality together. " "Creating a new class creates a new *type* of object, allowing new " "*instances* of that type to be made. Each class instance can have " "attributes attached to it for maintaining its state. Class instances can " "also have methods (defined by its class) for modifying its state." msgstr "" "ਕਲਾਸਾਂ ਡਾਟਾ ਅਤੇ ਕਾਰਜਕੁਸ਼ਲਤਾ ਨੂੰ ਇਕੱਠੇ ਸੰਗਠਿਤ ਕਰਨ ਦਾ ਇੱਕ ਤਰੀਕਾ ਪ੍ਰਦਾਨ ਕਰਦੀਆਂ ਹਨ। ਇੱਕ ਨਵੀਂ " "ਕਲਾਸ ਬਣਾਉਣ ਨਾਲ ਵਸਤੂ ਦੀ ਇੱਕ ਨਵੀਂ *ਕਿਸਮ* ਬਣਦੀ ਹੈ, ਜਿਸ ਨਾਲ ਉਸ ਕਿਸਮ ਦੇ ਨਵੇਂ *ਇੰਸਟੈਂਸ* ਬਣਾਏ " "ਜਾ ਸਕਦੇ ਹਨ। ਹਰ ਕਲਾਸ ਇੰਸਟੈਂਸ ਨਾਲ ਉਸਦੀ ਸਥਿਤੀ ਬਣਾਈ ਰੱਖਣ ਲਈ ਗੁਣ ਜੋੜੇ ਜਾ ਸਕਦੇ ਹਨ। ਕਲਾਸ " "ਇੰਸਟੈਂਸਾਂ ਵਿੱਚ ਉਨ੍ਹਾਂ ਦੀ ਸਥਿਤੀ ਨੂੰ ਬਦਲਣ ਲਈ ਵਿਧੀਆਂ (methods) ਵੀ ਹੋ ਸਕਦੀਆਂ ਹਨ, ਜੋ ਕਲਾਸ ਵੱਲੋਂ " "ਪਰਿਭਾਸ਼ਿਤ ਕੀਤੀਆਂ ਜਾਂਦੀਆਂ ਹਨ।" msgid "" "Compared with other programming languages, Python's class mechanism adds " "classes with a minimum of new syntax and semantics. It is a mixture of the " "class mechanisms found in C++ and Modula-3. Python classes provide all the " "standard features of Object Oriented Programming: the class inheritance " "mechanism allows multiple base classes, a derived class can override any " "methods of its base class or classes, and a method can call the method of a " "base class with the same name. Objects can contain arbitrary amounts and " "kinds of data. As is true for modules, classes partake of the dynamic " "nature of Python: they are created at runtime, and can be modified further " "after creation." msgstr "" "ਹੋਰ ਪ੍ਰੋਗਰਾਮਿੰਗ ਭਾਸ਼ਾਵਾਂ ਨਾਲ ਤੁਲਨਾ ਕਰਨ ਤੇ, Python ਦੀ ਕਲਾਸ ਪ੍ਰਣਾਲੀ ਘੱਟ ਤੋਂ ਘੱਟ ਨਵੇਂ ਸਿੰਟੈਕਸ ਅਤੇ " "ਅਰਥਾਤਮਕ ਨਿਯਮਾਂ ਨਾਲ ਕਲਾਸਾਂ ਪ੍ਰਦਾਨ ਕਰਦੀ ਹੈ। ਇਹ C++ ਅਤੇ Modula-3 ਵਿੱਚ ਮਿਲਣ ਵਾਲੀਆਂ ਕਲਾਸ " "ਪ੍ਰਣਾਲੀਆਂ ਦਾ ਮਿਲਾਪ ਹੈ। Python ਦੀਆਂ ਕਲਾਸਾਂ ਆਬਜੈਕਟ-ਓਰੀਐਂਟਿਡ ਪ੍ਰੋਗਰਾਮਿੰਗ ਦੀਆਂ ਸਾਰੀਆਂ ਮਿਆਰੀ " "ਵਿਸ਼ੇਸ਼ਤਾਵਾਂ ਪ੍ਰਦਾਨ ਕਰਦੀਆਂ ਹਨ। ਕਲਾਸ ਇਨਹੈਰਿਟੈਂਸ ਪ੍ਰਣਾਲੀ ਕਈ ਬੇਸ ਕਲਾਸਾਂ ਦੀ ਆਗਿਆ ਦਿੰਦੀ ਹੈ, " "ਡਿਰਾਈਵਡ ਕਲਾਸ ਆਪਣੀ ਬੇਸ ਕਲਾਸ ਜਾਂ ਕਲਾਸਾਂ ਦੀਆਂ ਕਿਸੇ ਵੀ ਮੈਥਡਾਂ ਨੂੰ ਓਵਰਰਾਈਡ ਕਰ ਸਕਦੀ ਹੈ ਅਤੇ ਕੋਈ " "ਮੈਥਡ ਉਸੇ ਨਾਮ ਵਾਲੀ ਬੇਸ ਕਲਾਸ ਦੀ ਮੈਥਡ ਨੂੰ ਕਾਲ ਕਰ ਸਕਦੀ ਹੈ। ਆਬਜੈਕਟ ਕਿਸੇ ਵੀ ਮਾਤਰਾ ਅਤੇ ਕਿਸਮ " "ਦਾ ਡਾਟਾ ਰੱਖ ਸਕਦੇ ਹਨ। ਮੌਡਿਊਲਾਂ ਵਾਂਗ, ਕਲਾਸਾਂ ਵੀ Python ਦੇ ਗਤੀਸ਼ੀਲ ਸੁਭਾਵ ਦਾ ਹਿੱਸਾ ਹਨ: ਉਹ " "ਰਨਟਾਈਮ ਦੌਰਾਨ ਬਣਦੀਆਂ ਹਨ ਅਤੇ ਬਣਨ ਤੋਂ ਬਾਅਦ ਵੀ ਸੋਧੀਆਂ ਜਾ ਸਕਦੀਆਂ ਹਨ।" msgid "" "In C++ terminology, normally class members (including the data members) are " "*public* (except see below :ref:`tut-private`), and all member functions are " "*virtual*. As in Modula-3, there are no shorthands for referencing the " "object's members from its methods: the method function is declared with an " "explicit first argument representing the object, which is provided " "implicitly by the call. As in Smalltalk, classes themselves are objects. " "This provides semantics for importing and renaming. Unlike C++ and " "Modula-3, built-in types can be used as base classes for extension by the " "user. Also, like in C++, most built-in operators with special syntax " "(arithmetic operators, subscripting etc.) can be redefined for class " "instances." msgstr "" "C++ ਦੀ ਟਰਮੀਨੋਲੋਜੀ ਵਿੱਚ, ਆਮ ਤੌਰ 'ਤੇ ਕਲਾਸ ਮੈਂਬਰ (ਡਾਟਾ ਮੈਂਬਰ ਸਮੇਤ) *public* ਹੁੰਦੇ ਹਨ " "(ਹੇਠਾਂ :ref:`tut-private` ਵੇਖੋ), ਅਤੇ ਸਾਰੇ ਮੈਂਬਰ ਫੰਕਸ਼ਨ *virtual* ਹੁੰਦੇ ਹਨ। Modula-3 ਵਾਂਗ, " "ਵਿਧੀਆਂ ਦੇ ਅੰਦਰੋਂ ਆਬਜੈਕਟ ਦੇ ਮੈਂਬਰਾਂ ਨੂੰ ਹਵਾਲਾ ਦੇਣ ਲਈ ਕੋਈ ਸੰਖੇਪ ਰੂਪ ਨਹੀਂ ਹੈ। ਮੈਥਡ ਫੰਕਸ਼ਨ ਨੂੰ ਆਬਜੈਕਟ ਨੂੰ " "ਦਰਸਾਉਂਦੇ ਇੱਕ ਸਪਸ਼ਟ ਪਹਿਲੇ ਆਰਗੂਮੈਂਟ ਨਾਲ ਘੋਸ਼ਿਤ ਕੀਤਾ ਜਾਂਦਾ ਹੈ, ਜੋ ਕਾਲ ਵੇਲੇ ਆਪਣੇ ਆਪ ਪ੍ਰਦਾਨ ਕੀਤਾ " "ਜਾਂਦਾ ਹੈ। Smalltalk ਵਾਂਗ, ਕਲਾਸਾਂ ਖੁਦ ਵੀ ਆਬਜੈਕਟ ਹੁੰਦੀਆਂ ਹਨ। ਇਹ ਇੰਪੋਰਟ ਅਤੇ ਰੀਨੇਮਿੰਗ ਲਈ " "ਅਰਥਾਤਮਕ ਸਮਰਥਨ ਪ੍ਰਦਾਨ ਕਰਦਾ ਹੈ। C++ ਅਤੇ Modula-3 ਤੋਂ ਵੱਖਰਾ, ਬਿਲਟ-ਇਨ ਟਾਈਪਾਂ ਨੂੰ ਯੂਜ਼ਰ ਦੁਆਰਾ " "ਐਕਸਟੈਂਸ਼ਨ ਲਈ ਬੇਸ ਕਲਾਸ ਵਜੋਂ ਵਰਤਿਆ ਜਾ ਸਕਦਾ ਹੈ। ਇਸ ਤੋਂ ਇਲਾਵਾ, C++ ਵਾਂਗ ਖਾਸ ਸਿੰਟੈਕਸ ਵਾਲੇ ਬਹੁਤੇ " "ਬਿਲਟ-ਇਨ ਓਪਰੇਟਰ (ਅੰਕਗਣਿਤ ਓਪਰੇਟਰ, ਸਬਸਕ੍ਰਿਪਟਿੰਗ ਆਦਿ) ਕਲਾਸ ਇੰਸਟੈਂਸਾਂ ਲਈ ਮੁੜ ਪਰਿਭਾਸ਼ਿਤ ਕੀਤੇ " "ਜਾ ਸਕਦੇ ਹਨ।" msgid "" "(Lacking universally accepted terminology to talk about classes, I will make " "occasional use of Smalltalk and C++ terms. I would use Modula-3 terms, " "since its object-oriented semantics are closer to those of Python than C++, " "but I expect that few readers have heard of it.)" msgstr "" "(ਕਲਾਸਾਂ ਬਾਰੇ ਗੱਲ ਕਰਨ ਲਈ ਕੋਈ ਸਰਵਮਾਨਯ ਟਰਮੀਨੋਲੋਜੀ ਨਾ ਹੋਣ ਕਰਕੇ, ਮੈਂ ਕਦੇ-ਕਦੇ Smalltalk ਅਤੇ C++ " "ਦੇ ਸ਼ਬਦ ਵਰਤਾਂਗਾ। ਮੈਂ Modula-3 ਦੇ ਸ਼ਬਦ ਵਰਤ ਸਕਦਾ ਸੀ ਕਿਉਂਕਿ ਇਸਦੇ ਆਬਜੈਕਟ-ਓਰੀਐਂਟਿਡ ਨਿਯਮ C++ " "ਨਾਲੋਂ Python ਦੇ ਵਧੇਰੇ ਨੇੜੇ ਹਨ, ਪਰ ਮੈਨੂੰ ਲੱਗਦਾ ਹੈ ਕਿ ਬਹੁਤ ਘੱਟ ਪਾਠਕਾਂ ਨੇ ਇਸ ਬਾਰੇ ਸੁਣਿਆ ਹੋਵੇਗਾ।)" msgid "A Word About Names and Objects" msgstr "ਨਾਂਵਾਂ ਅਤੇ ਆਬਜੈਕਟਾਂ ਬਾਰੇ ਇੱਕ ਗੱਲ" msgid "" "Objects have individuality, and multiple names (in multiple scopes) can be " "bound to the same object. This is known as aliasing in other languages. " "This is usually not appreciated on a first glance at Python, and can be " "safely ignored when dealing with immutable basic types (numbers, strings, " "tuples). However, aliasing has a possibly surprising effect on the " "semantics of Python code involving mutable objects such as lists, " "dictionaries, and most other types. This is usually used to the benefit of " "the program, since aliases behave like pointers in some respects. For " "example, passing an object is cheap since only a pointer is passed by the " "implementation; and if a function modifies an object passed as an argument, " "the caller will see the change --- this eliminates the need for two " "different argument passing mechanisms as in Pascal." msgstr "" "ਵਸਤੂਆਂ ਦੀ ਵਿਲੱਖਣਤਾ ਹੁੰਦੀ ਹੈ, ਅਤੇ ਇੱਕੋ ਵਸਤੂ ਨੂੰ ਵੱਖ-ਵੱਖ scopes ਵਿੱਚ ਕਈ ਨਾਮ ਬੰਨ੍ਹੇ ਜਾ ਸਕਦੇ ਹਨ। " "ਇਸਨੂੰ ਹੋਰ ਭਾਸ਼ਾਵਾਂ ਵਿੱਚ aliasing ਕਿਹਾ ਜਾਂਦਾ ਹੈ। Python 'ਤੇ ਪਹਿਲੀ ਨਜ਼ਰ 'ਚ ਇਹ ਆਮ ਤੌਰ 'ਤੇ " "ਧਿਆਨ ਵਿੱਚ ਨਹੀਂ ਆਉਂਦਾ, ਅਤੇ immutable ਬੁਨਿਆਦੀ ਕਿਸਮਾਂ (numbers, strings, tuples) ਨਾਲ " "ਕੰਮ ਕਰਦਿਆਂ ਇਸਨੂੰ ਸੁਰੱਖਿਅਤ ਤੌਰ 'ਤੇ ਨਜ਼ਰਅੰਦਾਜ਼ ਕੀਤਾ ਜਾ ਸਕਦਾ ਹੈ। ਹਾਲਾਂਕਿ, mutable ਵਸਤੂਆਂ (ਜਿਵੇਂ " "ਕਿ lists, dictionaries ਅਤੇ ਹੋਰ ਬਹੁਤ ਸਾਰੀਆਂ ਕਿਸਮਾਂ) ਨਾਲ ਸੰਬੰਧਿਤ Python code ਦੇ " "semantics 'ਤੇ aliasing ਦਾ ਹੈਰਾਨ ਕਰਨ ਵਾਲਾ ਪ੍ਰਭਾਵ ਹੋ ਸਕਦਾ ਹੈ। ਇਹ ਆਮ ਤੌਰ 'ਤੇ ਪ੍ਰੋਗਰਾਮ ਦੇ " "ਫਾਇਦੇ ਲਈ ਵਰਤਿਆ ਜਾਂਦਾ ਹੈ, ਕਿਉਂਕਿ ਕੁਝ ਮਾਮਲਿਆਂ ਵਿੱਚ aliases pointers ਵਾਂਗ ਹੀ ਵਿਹਾਰ ਕਰਦੇ " "ਹਨ। ਉਦਾਹਰਨ ਲਈ, ਇੱਕ object pass ਕਰਨਾ ਸਸਤਾ ਹੁੰਦਾ ਹੈ ਕਿਉਂਕਿ implementation ਦੁਆਰਾ ਸਿਰਫ਼ " "ਇੱਕ pointer ਹੀ pass ਕੀਤਾ ਜਾਂਦਾ ਹੈ; ਅਤੇ ਜੇਕਰ ਕੋਈ function argument ਵਜੋਂ ਦਿੱਤੇ ਗਏ object " "ਨੂੰ ਸੋਧਦਾ ਹੈ, ਤਾਂ caller ਨੂੰ ਇਹ ਤਬਦੀਲੀ ਦਿਖਾਈ ਦੇਵੇਗੀ --- ਇਹ Pascal ਵਾਂਗ ਦੋ ਵੱਖ-ਵੱਖ " "argument passing mechanisms ਦੀ ਲੋੜ ਨੂੰ ਖਤਮ ਕਰਦਾ ਹੈ।" msgid "Python Scopes and Namespaces" msgstr "Python ਵਿੱਚ ਸਕੋਪ ਅਤੇ ਨੇਮਸਪੇਸ" msgid "" "Before introducing classes, I first have to tell you something about " "Python's scope rules. Class definitions play some neat tricks with " "namespaces, and you need to know how scopes and namespaces work to fully " "understand what's going on. Incidentally, knowledge about this subject is " "useful for any advanced Python programmer." msgstr "" "ਕਲਾਸਾਂ ਦੀ ਜਾਣ-ਪਛਾਣ ਕਰਵਾਉਣ ਤੋਂ ਪਹਿਲਾਂ, ਮੈਨੂੰ ਤੁਹਾਨੂੰ Python ਦੇ ਸਕੋਪ ਨਿਯਮਾਂ ਬਾਰੇ ਕੁਝ ਦੱਸਣਾ " "ਪਵੇਗਾ। ਕਲਾਸ ਪਰਿਭਾਸ਼ਾਵਾਂ ਨੇਮਸਪੇਸ ਨਾਲ ਕੁਝ ਦਿਲਚਸਪ ਤਰੀਕੇ ਨਾਲ ਕੰਮ ਕਰਦੀਆਂ ਹਨ, ਅਤੇ ਜੋ ਕੁਝ ਹੋ " "ਰਿਹਾ ਹੈ ਉਸਨੂੰ ਪੂਰੀ ਤਰ੍ਹਾਂ ਸਮਝਣ ਲਈ ਤੁਹਾਨੂੰ ਸਕੋਪ ਅਤੇ ਨੇਮਸਪੇਸ ਦੀ ਕਾਰਵਾਈ ਨੂੰ ਜਾਣਨਾ ਲਾਜ਼ਮੀ ਹੈ। ਇਸ " "ਤੋਂ ਇਲਾਵਾ, ਇਸ ਵਿਸ਼ੇ ਬਾਰੇ ਗਿਆਨ ਕਿਸੇ ਵੀ ਉੱਨਤ Python ਪ੍ਰੋਗਰਾਮਰ ਲਈ ਲਾਭਦਾਇਕ ਹੈ।" msgid "Let's begin with some definitions." msgstr "ਆਓ ਕੁਝ ਪਰਿਭਾਸ਼ਾਵਾਂ ਨਾਲ ਸ਼ੁਰੂ ਕਰੀਏ।" msgid "" "A *namespace* is a mapping from names to objects. Most namespaces are " "currently implemented as Python dictionaries, but that's normally not " "noticeable in any way (except for performance), and it may change in the " "future. Examples of namespaces are: the set of built-in names (containing " "functions such as :func:`abs`, and built-in exception names); the global " "names in a module; and the local names in a function invocation. In a sense " "the set of attributes of an object also form a namespace. The important " "thing to know about namespaces is that there is absolutely no relation " "between names in different namespaces; for instance, two different modules " "may both define a function ``maximize`` without confusion --- users of the " "modules must prefix it with the module name." msgstr "" "ਇੱਕ *ਨੇਮਸਪੇਸ* ਨਾਮਾਂ ਅਤੇ ਆਬਜੈਕਟਾਂ ਵਿਚਕਾਰ ਇੱਕ ਮੈਪਿੰਗ ਹੁੰਦੀ ਹੈ। ਜ਼ਿਆਦਾਤਰ ਨੇਮਸਪੇਸ ਇਸ ਸਮੇਂ Python " "ਡਿਕਸ਼ਨਰੀਆਂ ਰਾਹੀਂ ਲਾਗੂ ਕੀਤੇ ਜਾਂਦੇ ਹਨ, ਪਰ ਇਹ ਗੱਲ ਆਮ ਤੌਰ 'ਤੇ ਦਿਖਾਈ ਨਹੀਂ ਦਿੰਦੀ (ਕਾਰਗੁਜ਼ਾਰੀ ਤੋਂ " "ਇਲਾਵਾ) ਅਤੇ ਭਵਿੱਖ ਵਿੱਚ ਬਦਲ ਵੀ ਸਕਦੀ ਹੈ। ਨੇਮਸਪੇਸਾਂ ਦੇ ਉਦਾਹਰਨ ਹਨ: ਬਿਲਟ-ਇਨ ਨਾਮਾਂ ਦਾ ਸਮੂਹ " "(ਜਿਸ ਵਿੱਚ :func:`abs` ਵਰਗੇ ਫੰਕਸ਼ਨ ਅਤੇ ਬਿਲਟ-ਇਨ ਐਕਸੈਪਸ਼ਨ ਨਾਮ ਸ਼ਾਮਲ ਹਨ), ਕਿਸੇ ਮੌਡਿਊਲ ਦੇ " "ਗਲੋਬਲ ਨਾਮ, ਅਤੇ ਕਿਸੇ ਫੰਕਸ਼ਨ ਕਾਲ ਦੇ ਸਥਾਨਕ ਨਾਮ। ਇੱਕ ਅਰਥ ਵਿੱਚ, ਕਿਸੇ ਆਬਜੈਕਟ ਦੇ ਐਟ੍ਰਿਬਿਊਟਾਂ ਦਾ " "ਸਮੂਹ ਵੀ ਇੱਕ ਨੇਮਸਪੇਸ ਬਣਾਉਂਦਾ ਹੈ। ਨੇਮਸਪੇਸਾਂ ਬਾਰੇ ਸਭ ਤੋਂ ਮਹੱਤਵਪੂਰਨ ਗੱਲ ਇਹ ਹੈ ਕਿ ਵੱਖ-ਵੱਖ ਨੇਮਸਪੇਸਾਂ ਦੇ " "ਨਾਮਾਂ ਵਿਚਕਾਰ ਕੋਈ ਸਿੱਧਾ ਸੰਬੰਧ ਨਹੀਂ ਹੁੰਦਾ। ਉਦਾਹਰਨ ਵਜੋਂ, ਦੋ ਵੱਖਰੇ ਮੌਡਿਊਲ ``maximize`` ਨਾਮ ਦਾ " "ਫੰਕਸ਼ਨ ਪਰਿਭਾਸ਼ਿਤ ਕਰ ਸਕਦੇ ਹਨ ਅਤੇ ਕੋਈ ਉਲਝਣ ਨਹੀਂ ਹੁੰਦੀ — ਵਰਤੋਂਕਾਰਾਂ ਨੂੰ ਮੌਡਿਊਲ ਦੇ ਨਾਮ ਨਾਲ ਇਸਦਾ " "ਹਵਾਲਾ ਦੇਣਾ ਪੈਂਦਾ ਹੈ।" msgid "" "By the way, I use the word *attribute* for any name following a dot --- for " "example, in the expression ``z.real``, ``real`` is an attribute of the " "object ``z``. Strictly speaking, references to names in modules are " "attribute references: in the expression ``modname.funcname``, ``modname`` is " "a module object and ``funcname`` is an attribute of it. In this case there " "happens to be a straightforward mapping between the module's attributes and " "the global names defined in the module: they share the same namespace! [#]_" msgstr "" "ਵੈਸੇ, ਮੈਂ ਡੌਟ ਤੋਂ ਬਾਅਦ ਆਉਣ ਵਾਲੇ ਕਿਸੇ ਵੀ ਨਾਮ ਲਈ *ਐਟ੍ਰਿਬਿਊਟ* ਸ਼ਬਦ ਵਰਤਦਾ ਹਾਂ। ਉਦਾਹਰਨ ਵਜੋਂ, " "``z.real`` ਐਕਸਪ੍ਰੈਸ਼ਨ ਵਿੱਚ ``real`` ਆਬਜੈਕਟ ``z`` ਦਾ ਇੱਕ ਐਟ੍ਰਿਬਿਊਟ ਹੈ। ਸਖ਼ਤੀ ਨਾਲ ਕਹੀਏ " "ਤਾਂ ਮੌਡਿਊਲਾਂ ਵਿੱਚ ਨਾਮਾਂ ਦੇ ਹਵਾਲੇ ਵੀ ਐਟ੍ਰਿਬਿਊਟ ਹਵਾਲੇ ਹੀ ਹੁੰਦੇ ਹਨ। ``modname.funcname`` " "ਵਿੱਚ ``modname`` ਇੱਕ ਮੌਡਿਊਲ ਆਬਜੈਕਟ ਹੈ ਅਤੇ ``funcname`` ਉਸਦਾ ਐਟ੍ਰਿਬਿਊਟ ਹੈ। ਇਸ ਮਾਮਲੇ " "ਵਿੱਚ ਮੌਡਿਊਲ ਦੇ ਐਟ੍ਰਿਬਿਊਟਾਂ ਅਤੇ ਉਸ ਵਿੱਚ ਪਰਿਭਾਸ਼ਿਤ ਗਲੋਬਲ ਨਾਮਾਂ ਵਿਚਕਾਰ ਸਿੱਧੀ ਮੈਪਿੰਗ ਹੁੰਦੀ ਹੈ ਅਤੇ " "ਉਹ ਇੱਕੋ ਨੇਮਸਪੇਸ ਸਾਂਝਾ ਕਰਦੇ ਹਨ। [#]_" msgid "" "Attributes may be read-only or writable. In the latter case, assignment to " "attributes is possible. Module attributes are writable: you can write " "``modname.the_answer = 42``. Writable attributes may also be deleted with " "the :keyword:`del` statement. For example, ``del modname.the_answer`` will " "remove the attribute :attr:`!the_answer` from the object named by " "``modname``." msgstr "" "ਐਟ੍ਰਿਬਿਊਟ ਸਿਰਫ਼-ਪੜ੍ਹਨਯੋਗ ਜਾਂ ਲਿਖਣਯੋਗ ਹੋ ਸਕਦੇ ਹਨ। ਲਿਖਣਯੋਗ ਐਟ੍ਰਿਬਿਊਟਾਂ ਨੂੰ ਮੁੱਲ ਅਸਾਈਨ ਕੀਤਾ ਜਾ " "ਸਕਦਾ ਹੈ। ਮੌਡਿਊਲ ਐਟ੍ਰਿਬਿਊਟ ਲਿਖਣਯੋਗ ਹੁੰਦੇ ਹਨ, ਉਦਾਹਰਨ ਵਜੋਂ ਤੁਸੀਂ ``modname.the_answer = " "42`` ਲਿਖ ਸਕਦੇ ਹੋ। ਲਿਖਣਯੋਗ ਐਟ੍ਰਿਬਿਊਟਾਂ ਨੂੰ :keyword:`del` ਸਟੇਟਮੈਂਟ ਨਾਲ ਹਟਾਇਆ ਵੀ ਜਾ ਸਕਦਾ " "ਹੈ। ਉਦਾਹਰਨ ਲਈ, ``del modname.the_answer`` ``modname`` ਨਾਮਕ ਆਬਜੈਕਟ ਤੋਂ :attr:`!" "the_answer` ਐਟ੍ਰਿਬਿਊਟ ਨੂੰ ਹਟਾ ਦੇਵੇਗਾ।" msgid "" "Namespaces are created at different moments and have different lifetimes. " "The namespace containing the built-in names is created when the Python " "interpreter starts up, and is never deleted. The global namespace for a " "module is created when the module definition is read in; normally, module " "namespaces also last until the interpreter quits. The statements executed " "by the top-level invocation of the interpreter, either read from a script " "file or interactively, are considered part of a module " "called :mod:`__main__`, so they have their own global namespace. (The built-" "in names actually also live in a module; this is called :mod:`builtins`.)" msgstr "" "ਨੇਮਸਪੇਸ ਵੱਖ-ਵੱਖ ਸਮਿਆਂ 'ਤੇ ਬਣਾਏ ਜਾਂਦੇ ਹਨ ਅਤੇ ਉਨ੍ਹਾਂ ਦੀ ਉਮਰ ਵੀ ਵੱਖਰੀ ਹੁੰਦੀ ਹੈ। ਬਿਲਟ-ਇਨ ਨਾਮਾਂ " "ਵਾਲਾ ਨੇਮਸਪੇਸ Python ਇੰਟਰਪ੍ਰੀਟਰ ਦੇ ਸ਼ੁਰੂ ਹੋਣ ਸਮੇਂ ਬਣਦਾ ਹੈ ਅਤੇ ਕਦੇ ਮਿਟਾਇਆ ਨਹੀਂ ਜਾਂਦਾ। ਕਿਸੇ " "ਮੌਡਿਊਲ ਦਾ ਗਲੋਬਲ ਨੇਮਸਪੇਸ ਮੌਡਿਊਲ ਦੀ ਪਰਿਭਾਸ਼ਾ ਪੜ੍ਹੇ ਜਾਣ ਸਮੇਂ ਬਣਦਾ ਹੈ ਅਤੇ ਆਮ ਤੌਰ 'ਤੇ ਇੰਟਰਪ੍ਰੀਟਰ " "ਬੰਦ ਹੋਣ ਤੱਕ ਮੌਜੂਦ ਰਹਿੰਦਾ ਹੈ। ਇੰਟਰਪ੍ਰੀਟਰ ਦੇ ਉੱਚ-ਪੱਧਰੀ ਚਲਾਓ ਦੌਰਾਨ ਚਲਣ ਵਾਲੀਆਂ ਸਟੇਟਮੈਂਟਾਂ, ਭਾਵੇਂ ਉਹ " "ਸਕ੍ਰਿਪਟ ਫਾਈਲ ਤੋਂ ਪੜ੍ਹੀਆਂ ਗਈਆਂ ਹੋਣ ਜਾਂ ਇੰਟਰਐਕਟਿਵ ਤਰੀਕੇ ਨਾਲ, :mod:`__main__` ਨਾਮਕ ਮੌਡਿਊਲ " "ਦਾ ਹਿੱਸਾ ਮੰਨੀਆਂ ਜਾਂਦੀਆਂ ਹਨ, ਇਸ ਲਈ ਉਹਨਾਂ ਦਾ ਆਪਣਾ ਗਲੋਬਲ ਨੇਮਸਪੇਸ ਹੁੰਦਾ ਹੈ। (ਬਿਲਟ-ਇਨ ਨਾਮ ਅਸਲ " "ਵਿੱਚ :mod:`builtins` ਮੌਡਿਊਲ ਵਿੱਚ ਮੌਜੂਦ ਹੁੰਦੇ ਹਨ।)" msgid "" "The local namespace for a function is created when the function is called, " "and deleted when the function returns or raises an exception that is not " "handled within the function. (Actually, forgetting would be a better way to " "describe what actually happens.) Of course, recursive invocations each have " "their own local namespace." msgstr "" "ਕਿਸੇ ਫੰਕਸ਼ਨ ਦਾ ਸਥਾਨਕ ਨੇਮਸਪੇਸ ਉਸ ਵੇਲੇ ਬਣਦਾ ਹੈ ਜਦੋਂ ਫੰਕਸ਼ਨ ਕਾਲ ਕੀਤਾ ਜਾਂਦਾ ਹੈ ਅਤੇ ਜਦੋਂ ਫੰਕਸ਼ਨ ਮੁੜਦਾ " "ਹੈ ਜਾਂ ਕੋਈ ਐਸੀ ਐਕਸੈਪਸ਼ਨ ਪੈਦਾ ਕਰਦਾ ਹੈ ਜੋ ਫੰਕਸ਼ਨ ਦੇ ਅੰਦਰ ਹੈਂਡਲ ਨਹੀਂ ਕੀਤੀ ਗਈ, ਤਾਂ ਇਹ ਮਿਟ ਜਾਂਦਾ " "ਹੈ। (ਅਸਲ ਵਿੱਚ, 'ਭੁੱਲ ਜਾਣਾ' ਇਸ ਪ੍ਰਕਿਰਿਆ ਦਾ ਵਧੀਆ ਵਰਣਨ ਹੈ।) ਬੇਸ਼ੱਕ, ਹਰ ਰਿਕਰਸਿਵ ਕਾਲ ਦਾ " "ਆਪਣਾ ਵੱਖਰਾ ਸਥਾਨਕ ਨੇਮਸਪੇਸ ਹੁੰਦਾ ਹੈ।" msgid "" "A *scope* is a textual region of a Python program where a namespace is " "directly accessible. \"Directly accessible\" here means that an unqualified " "reference to a name attempts to find the name in the namespace." msgstr "" "ਇੱਕ *ਸਕੋਪ* Python ਪ੍ਰੋਗਰਾਮ ਦਾ ਉਹ ਪਾਠਕ ਖੇਤਰ ਹੁੰਦਾ ਹੈ ਜਿੱਥੇ ਇੱਕ ਨੇਮਸਪੇਸ ਤੱਕ ਸਿੱਧੀ ਪਹੁੰਚ ਹੁੰਦੀ ਹੈ। " "ਇੱਥੇ \"ਸਿੱਧੀ ਪਹੁੰਚ\" ਦਾ ਅਰਥ ਹੈ ਕਿ ਕਿਸੇ ਨਾਂ ਦੇ ਬਿਨਾਂ ਯੋਗਤਾ ਵਾਲੇ ਹਵਾਲੇ ਦੁਆਰਾ ਉਸ ਨਾਂ ਨੂੰ ਨੇਮਸਪੇਸ " "ਵਿੱਚ ਲੱਭਣ ਦੀ ਕੋਸ਼ਿਸ਼ ਕੀਤੀ ਜਾਂਦੀ ਹੈ।" msgid "" "Although scopes are determined statically, they are used dynamically. At any " "time during execution, there are 3 or 4 nested scopes whose namespaces are " "directly accessible:" msgstr "" "ਹਾਲਾਂਕਿ ਸਕੋਪਾਂ ਦਾ ਨਿਰਧਾਰਣ ਸਥਿਰ ਤਰੀਕੇ ਨਾਲ ਹੁੰਦਾ ਹੈ, ਪਰ ਉਹਨਾਂ ਦੀ ਵਰਤੋਂ ਗਤੀਸ਼ੀਲ ਤਰੀਕੇ ਨਾਲ " "ਕੀਤੀ ਜਾਂਦੀ ਹੈ। ਐਗਜ਼ਿਕਿਊਸ਼ਨ ਦੇ ਕਿਸੇ ਵੀ ਸਮੇਂ 3 ਜਾਂ 4 ਨੇਸਟਡ ਸਕੋਪ ਹੁੰਦੇ ਹਨ ਜਿਨ੍ਹਾਂ ਦੇ ਨੇਮਸਪੇਸ ਸਿੱਧੇ " "ਤੌਰ 'ਤੇ ਪਹੁੰਚਯੋਗ ਹੁੰਦੇ ਹਨ:" msgid "the innermost scope, which is searched first, contains the local names" msgstr "ਸਭ ਤੋਂ ਅੰਦਰਲਾ ਸਕੋਪ, ਜਿਸ ਦੀ ਪਹਿਲਾਂ ਖੋਜ ਕੀਤੀ ਜਾਂਦੀ ਹੈ, ਸਥਾਨਕ ਨਾਂਵਾਂ ਨੂੰ ਰੱਖਦਾ ਹੈ" msgid "" "the scopes of any enclosing functions, which are searched starting with the " "nearest enclosing scope, contain non-local, but also non-global names" msgstr "" "ਘੇਰਨ ਵਾਲੇ ਫੰਕਸ਼ਨਾਂ ਦੇ ਸਕੋਪ, ਜਿਨ੍ਹਾਂ ਦੀ ਖੋਜ ਸਭ ਤੋਂ ਨੇੜਲੇ ਸਕੋਪ ਤੋਂ ਸ਼ੁਰੂ ਹੁੰਦੀ ਹੈ, ਗੈਰ-ਸਥਾਨਕ ਪਰ ਗੈਰ-" "ਗਲੋਬਲ ਨਾਂਵਾਂ ਨੂੰ ਰੱਖਦੇ ਹਨ" msgid "the next-to-last scope contains the current module's global names" msgstr "ਆਖਰੀ ਤੋਂ ਪਹਿਲਾਂ ਵਾਲਾ ਸਕੋਪ ਮੌਜੂਦਾ ਮੌਡਿਊਲ ਦੇ ਗਲੋਬਲ ਨਾਂਵਾਂ ਨੂੰ ਰੱਖਦਾ ਹੈ" msgid "" "the outermost scope (searched last) is the namespace containing built-in " "names" msgstr "" "ਸਭ ਤੋਂ ਬਾਹਰਲਾ ਸਕੋਪ (ਜਿਸ ਦੀ ਖੋਜ ਸਭ ਤੋਂ ਆਖਿਰ ਵਿੱਚ ਹੁੰਦੀ ਹੈ) ਬਿਲਟ-ਇਨ ਨਾਂਵਾਂ ਵਾਲਾ ਨੇਮਸਪੇਸ ਹੁੰਦਾ ਹੈ" msgid "" "If a name is declared global, then all references and assignments go " "directly to the next-to-last scope containing the module's global names. To " "rebind variables found outside of the innermost scope, " "the :keyword:`nonlocal` statement can be used; if not declared nonlocal, " "those variables are read-only (an attempt to write to such a variable will " "simply create a *new* local variable in the innermost scope, leaving the " "identically named outer variable unchanged)." msgstr "" "ਜੇ ਕਿਸੇ ਨਾਮ ਨੂੰ global ਘੋਸ਼ਿਤ ਕੀਤਾ ਗਿਆ ਹੋਵੇ, ਤਾਂ ਉਸ ਨਾਮ ਨਾਲ ਸੰਬੰਧਿਤ ਸਾਰੇ ਹਵਾਲੇ ਅਤੇ " "assignments ਸਿੱਧੇ ਮੋਡੀਊਲ ਦੇ global ਨਾਂਵਾਂ ਵਾਲੇ ਸਕੋਪ ਵਿੱਚ ਜਾਂਦੇ ਹਨ। ਸਭ ਤੋਂ ਅੰਦਰਲੇ ਸਕੋਪ ਤੋਂ ਬਾਹਰ " "ਮੌਜੂਦ ਵੇਰੀਏਬਲਾਂ ਨੂੰ ਮੁੜ ਬਾਈਂਡ ਕਰਨ ਲਈ :keyword:`nonlocal` ਸਟੇਟਮੈਂਟ ਵਰਤੀ ਜਾ ਸਕਦੀ ਹੈ। ਜੇਕਰ " "ਉਨ੍ਹਾਂ ਨੂੰ nonlocal ਘੋਸ਼ਿਤ ਨਾ ਕੀਤਾ ਗਿਆ ਹੋਵੇ, ਤਾਂ ਉਹ ਸਿਰਫ਼-ਪੜ੍ਹਨਯੋਗ ਰਹਿੰਦੇ ਹਨ (ਅਜਿਹੇ ਵੇਰੀਏਬਲ " "ਵਿੱਚ ਲਿਖਣ ਦੀ ਕੋਸ਼ਿਸ਼ ਕਰਨ ਨਾਲ ਅੰਦਰਲੇ ਸਕੋਪ ਵਿੱਚ ਇੱਕ *ਨਵਾਂ* ਸਥਾਨਕ ਵੇਰੀਏਬਲ ਬਣ ਜਾਂਦਾ ਹੈ ਅਤੇ " "ਬਾਹਰਲੇ ਸਕੋਪ ਵਾਲਾ ਇੱਕੋ ਹੀ ਨਾਮ ਵਾਲਾ ਵੇਰੀਏਬਲ ਅਣਬਦਲਿਆ ਰਹਿੰਦਾ ਹੈ)।" msgid "" "Usually, the local scope references the local names of the (textually) " "current function. Outside functions, the local scope references the same " "namespace as the global scope: the module's namespace. Class definitions " "place yet another namespace in the local scope." msgstr "" "ਆਮ ਤੌਰ 'ਤੇ, ਸਥਾਨਕ ਸਕੋਪ (ਟੈਕਸਟੂਅਲ ਤੌਰ 'ਤੇ) ਮੌਜੂਦਾ ਫੰਕਸ਼ਨ ਦੇ ਸਥਾਨਕ ਨਾਮਾਂ ਨੂੰ ਹਵਾਲਾ ਦਿੰਦਾ ਹੈ। " "ਫੰਕਸ਼ਨਾਂ ਦੇ ਬਾਹਰ, ਸਥਾਨਕ ਸਕੋਪ ਗਲੋਬਲ ਸਕੋਪ ਵਾਂਗ ਹੀ ਮੋਡਿਊਲ ਦੇ ਨੇਮਸਪੇਸ ਨੂੰ ਹਵਾਲਾ ਦਿੰਦਾ ਹੈ। ਕਲਾਸ " "ਪਰਿਭਾਸ਼ਾਵਾਂ ਸਥਾਨਕ ਸਕੋਪ ਵਿੱਚ ਇੱਕ ਹੋਰ ਨੇਮਸਪੇਸ ਸ਼ਾਮਿਲ ਕਰਦੀਆਂ ਹਨ।" msgid "" "It is important to realize that scopes are determined textually: the global " "scope of a function defined in a module is that module's namespace, no " "matter from where or by what alias the function is called. On the other " "hand, the actual search for names is done dynamically, at run time --- " "however, the language definition is evolving towards static name resolution, " "at \"compile\" time, so don't rely on dynamic name resolution! (In fact, " "local variables are already determined statically.)" msgstr "" "ਇਹ ਸਮਝਣਾ ਮਹੱਤਵਪੂਰਨ ਹੈ ਕਿ ਸਕੋਪ ਪਾਠਕ ਰੂਪ ਵਿੱਚ ਨਿਰਧਾਰਤ ਹੁੰਦੇ ਹਨ: ਕਿਸੇ ਮੋਡੀਊਲ ਵਿੱਚ ਪਰਿਭਾਸ਼ਿਤ " "ਫੰਕਸ਼ਨ ਦਾ ਗਲੋਬਲ ਸਕੋਪ ਉਸ ਮੋਡੀਊਲ ਦਾ namespace ਹੁੰਦਾ ਹੈ, ਭਾਵੇਂ ਫੰਕਸ਼ਨ ਨੂੰ ਕਿੱਥੋਂ ਜਾਂ ਕਿਸ alias " "ਰਾਹੀਂ ਕਾਲ ਕੀਤਾ ਜਾਵੇ। ਦੂਜੇ ਪਾਸੇ, ਨਾਮਾਂ ਦੀ ਅਸਲ ਖੋਜ ਚਲਾਉਣ ਸਮੇਂ run time ਗਤੀਸ਼ੀਲ ਤਰੀਕੇ ਨਾਲ " "ਕੀਤੀ ਜਾਂਦੀ ਹੈ --- ਹਾਲਾਂਕਿ, ਭਾਸ਼ਾ ਦੀ ਪਰਿਭਾਸ਼ਾ \"compile\" ਸਮੇਂ static name " "resolution ਵੱਲ ਵਿਕਸਿਤ ਹੋ ਰਹੀ ਹੈ, ਇਸ ਲਈ ਗਤੀਸ਼ੀਲ ਨਾਮ-ਨਿਰਣੇ ਉੱਤੇ ਨਿਰਭਰ ਨਾ ਕਰੋ! (ਅਸਲ " "ਵਿੱਚ, ਲੋਕਲ ਵੇਰੀਏਬਲ ਪਹਿਲਾਂ ਹੀ ਸਥਿਰ ਤਰੀਕੇ ਨਾਲ ਨਿਰਧਾਰਤ ਕੀਤੇ ਜਾਂਦੇ ਹਨ।)" msgid "" "A special quirk of Python is that -- if no :keyword:`global` " "or :keyword:`nonlocal` statement is in effect -- assignments to names always " "go into the innermost scope. Assignments do not copy data --- they just bind " "names to objects. The same is true for deletions: the statement ``del x`` " "removes the binding of ``x`` from the namespace referenced by the local " "scope. In fact, all operations that introduce new names use the local " "scope: in particular, :keyword:`import` statements and function definitions " "bind the module or function name in the local scope." msgstr "" "Python ਦੀ ਇੱਕ ਖਾਸ ਵਿਸ਼ੇਸ਼ਤਾ ਇਹ ਹੈ ਕਿ -- ਜੇ :keyword:`global` " "ਜਾਂ :keyword:`nonlocal` ਸਟੇਟਮੈਂਟ ਪ੍ਰਭਾਵ ਵਿੱਚ ਨਾ ਹੋਵੇ -- ਤਾਂ ਨਾਮਾਂ ਲਈ ਕੀਤੀਆਂ ਅਸਾਈਨਮੈਂਟਾਂ " "ਹਮੇਸ਼ਾਂ ਸਭ ਤੋਂ ਅੰਦਰਲੇ ਸਕੋਪ ਵਿੱਚ ਜਾਂਦੀਆਂ ਹਨ। ਅਸਾਈਨਮੈਂਟਾਂ ਡਾਟਾ ਦੀ ਨਕਲ ਨਹੀਂ ਕਰਦੀਆਂ --- ਇਹ ਸਿਰਫ਼ " "ਨਾਮਾਂ ਨੂੰ ਆਬਜੈਕਟਾਂ ਨਾਲ ਬੰਨ੍ਹਦੀਆਂ ਹਨ। ਇਹੀ ਗੱਲ ਮਿਟਾਉਣ ਲਈ ਵੀ ਸੱਚ ਹੈ: ``del x`` ਸਟੇਟਮੈਂਟ ਲੋਕਲ " "ਸਕੋਪ ਦੁਆਰਾ ਦਰਸਾਏ namespace ਵਿੱਚੋਂ ``x`` ਦੀ ਬਾਈਂਡਿੰਗ ਹਟਾ ਦਿੰਦਾ ਹੈ। ਦਰਅਸਲ, ਨਵੇਂ ਨਾਮ ਜੋੜਣ " "ਵਾਲੀਆਂ ਸਾਰੀਆਂ ਕਾਰਵਾਈਆਂ ਲੋਕਲ ਸਕੋਪ ਦੀ ਵਰਤੋਂ ਕਰਦੀਆਂ ਹਨ; ਖਾਸ ਤੌਰ 'ਤੇ, :keyword:`import` " "ਸਟੇਟਮੈਂਟ ਅਤੇ ਫੰਕਸ਼ਨ ਪਰਿਭਾਸ਼ਾਵਾਂ ਮੋਡੀਊਲ ਜਾਂ ਫੰਕਸ਼ਨ ਦੇ ਨਾਮ ਨੂੰ ਲੋਕਲ ਸਕੋਪ ਵਿੱਚ ਬੰਨ੍ਹਦੀਆਂ ਹਨ।" msgid "" "The :keyword:`global` statement can be used to indicate that particular " "variables live in the global scope and should be rebound there; " "the :keyword:`nonlocal` statement indicates that particular variables live " "in an enclosing scope and should be rebound there." msgstr "" ":keyword:`global` ਸਟੇਟਮੈਂਟ ਇਹ ਦਰਸਾਉਣ ਲਈ ਵਰਤੀ ਜਾਂਦੀ ਹੈ ਕਿ ਕੁਝ ਵੇਰੀਏਬਲ ਗਲੋਬਲ ਸਕੋਪ ਵਿੱਚ " "ਮੌਜੂਦ ਹਨ ਅਤੇ ਉਨ੍ਹਾਂ ਨੂੰ ਉੱਥੇ ਹੀ ਮੁੜ ਬਾਈਂਡ ਕੀਤਾ ਜਾਣਾ ਚਾਹੀਦਾ ਹੈ। :keyword:`nonlocal` ਸਟੇਟਮੈਂਟ " "ਇਹ ਦਰਸਾਉਂਦੀ ਹੈ ਕਿ ਕੁਝ ਵੇਰੀਏਬਲ ਕਿਸੇ ਘੇਰਨ ਵਾਲੇ ਸਕੋਪ ਵਿੱਚ ਮੌਜੂਦ ਹਨ ਅਤੇ ਉਨ੍ਹਾਂ ਨੂੰ ਉੱਥੇ ਹੀ ਮੁੜ ਬਾਈਂਡ " "ਕੀਤਾ ਜਾਣਾ ਚਾਹੀਦਾ ਹੈ।" msgid "Scopes and Namespaces Example" msgstr "ਸਕੋਪ ਅਤੇ ਨੇਮਸਪੇਸ ਦੀ ਉਦਾਹਰਨ" msgid "" "This is an example demonstrating how to reference the different scopes and " "namespaces, and how :keyword:`global` and :keyword:`nonlocal` affect " "variable binding::" msgstr "" "ਇਹ ਉਦਾਹਰਨ ਦਰਸਾਉਂਦੀ ਹੈ ਕਿ ਵੱਖ-ਵੱਖ ਸਕੋਪਾਂ ਅਤੇ ਨੇਮਸਪੇਸਾਂ ਦਾ ਹਵਾਲਾ ਕਿਵੇਂ ਦਿੱਤਾ ਜਾਂਦਾ ਹੈ " "ਅਤੇ :keyword:`global` ਅਤੇ :keyword:`nonlocal` ਵੇਰੀਏਬਲ ਬਾਈਂਡਿੰਗ ਨੂੰ ਕਿਵੇਂ ਪ੍ਰਭਾਵਿਤ ਕਰਦੇ " "ਹਨ::" msgid "" "def scope_test():\n" " def do_local():\n" " spam = \"local spam\"\n" "\n" " def do_nonlocal():\n" " nonlocal spam\n" " spam = \"nonlocal spam\"\n" "\n" " def do_global():\n" " global spam\n" " spam = \"global spam\"\n" "\n" " spam = \"test spam\"\n" " do_local()\n" " print(\"After local assignment:\", spam)\n" " do_nonlocal()\n" " print(\"After nonlocal assignment:\", spam)\n" " do_global()\n" " print(\"After global assignment:\", spam)\n" "\n" "scope_test()\n" "print(\"In global scope:\", spam)" msgstr "" "def scope_test():\n" " def do_local():\n" " spam = \"local spam\"\n" "\n" " def do_nonlocal():\n" " nonlocal spam\n" " spam = \"nonlocal spam\"\n" "\n" " def do_global():\n" " global spam\n" " spam = \"global spam\"\n" "\n" " spam = \"test spam\"\n" " do_local()\n" " print(\"After local assignment:\", spam)\n" " do_nonlocal()\n" " print(\"After nonlocal assignment:\", spam)\n" " do_global()\n" " print(\"After global assignment:\", spam)\n" "\n" "scope_test()\n" "print(\"In global scope:\", spam)" msgid "The output of the example code is:" msgstr "ਉਦਾਹਰਨ ਕੋਡ ਦਾ ਆਉਟਪੁੱਟ ਇਹ ਹੈ:" msgid "" "After local assignment: test spam\n" "After nonlocal assignment: nonlocal spam\n" "After global assignment: nonlocal spam\n" "In global scope: global spam" msgstr "" "After local assignment: test spam\n" "After nonlocal assignment: nonlocal spam\n" "After global assignment: nonlocal spam\n" "In global scope: global spam" msgid "" "Note how the *local* assignment (which is default) didn't change " "*scope_test*\\'s binding of *spam*. The :keyword:`nonlocal` assignment " "changed *scope_test*\\'s binding of *spam*, and the :keyword:`global` " "assignment changed the module-level binding." msgstr "" "ਧਿਆਨ ਦਿਓ ਕਿ *local* ਅਸਾਈਨਮੈਂਟ (ਜੋ ਮੂਲ ਵਰਤਾਰਾ ਹੈ) ਨੇ *scope_test* ਵਿੱਚ *spam* ਦੀ " "ਬਾਈਂਡਿੰਗ ਨਹੀਂ ਬਦਲੀ। :keyword:`nonlocal` ਅਸਾਈਨਮੈਂਟ ਨੇ *scope_test* ਦੀ *spam* ਬਾਈਂਡਿੰਗ " "ਬਦਲ ਦਿੱਤੀ, ਜਦਕਿ :keyword:`global` ਅਸਾਈਨਮੈਂਟ ਨੇ ਮੌਡਿਊਲ-ਪੱਧਰ ਦੀ ਬਾਈਂਡਿੰਗ ਬਦਲੀ।" msgid "" "You can also see that there was no previous binding for *spam* before " "the :keyword:`global` assignment." msgstr "" "ਤੁਸੀਂ ਇਹ ਵੀ ਦੇਖ ਸਕਦੇ ਹੋ ਕਿ :keyword:`global` ਅਸਾਈਨਮੈਂਟ ਤੋਂ ਪਹਿਲਾਂ *spam* ਲਈ ਕੋਈ ਪਿਛਲੀ " "ਬਾਈਂਡਿੰਗ ਮੌਜੂਦ ਨਹੀਂ ਸੀ।" msgid "A First Look at Classes" msgstr "ਕਲਾਸਾਂ ਨਾਲ ਪਹਿਲੀ ਜਾਣ-ਪਛਾਣ" msgid "" "Classes introduce a little bit of new syntax, three new object types, and " "some new semantics." msgstr "" "ਕਲਾਸਾਂ ਕੁਝ ਨਵਾਂ ਸਿੰਟੈਕਸ, ਤਿੰਨ ਨਵੀਆਂ ਵਸਤੂ ਕਿਸਮਾਂ ਅਤੇ ਕੁਝ ਨਵੇਂ ਅਰਥਾਤਮਕ ਨਿਯਮਾਂ ਦੀ ਜਾਣ-ਪਛਾਣ " "ਕਰਵਾਉਂਦੀਆਂ ਹਨ।" msgid "Class Definition Syntax" msgstr "ਕਲਾਸ ਪਰਿਭਾਸ਼ਾ ਦਾ ਸਿੰਟੈਕਸ" msgid "The simplest form of class definition looks like this::" msgstr "ਕਲਾਸ ਪਰਿਭਾਸ਼ਾ ਦਾ ਸਭ ਤੋਂ ਸਰਲ ਰੂਪ ਇਸ ਤਰ੍ਹਾਂ ਦਿਖਾਈ ਦਿੰਦਾ ਹੈ::" msgid "" "class ClassName:\n" " <statement-1>\n" " .\n" " .\n" " .\n" " <statement-N>" msgstr "" "class ClassName:\n" " <statement-1>\n" " .\n" " .\n" " .\n" " <statement-N>" msgid "" "Class definitions, like function definitions (:keyword:`def` statements) " "must be executed before they have any effect. (You could conceivably place " "a class definition in a branch of an :keyword:`if` statement, or inside a " "function.)" msgstr "" "ਕਲਾਸ ਪਰਿਭਾਸ਼ਾਵਾਂ, ਫੰਕਸ਼ਨ ਪਰਿਭਾਸ਼ਾਵਾਂ (:keyword:`def` ਸਟੇਟਮੈਂਟਾਂ) ਵਾਂਗ, ਕੋਈ ਪ੍ਰਭਾਵ ਪੈਦਾ ਕਰਨ " "ਤੋਂ ਪਹਿਲਾਂ ਚਲਾਈਆਂ ਜਾਣੀਆਂ ਲਾਜ਼ਮੀ ਹਨ। (ਉਦਾਹਰਨ ਲਈ, ਤੁਸੀਂ ਕਿਸੇ :keyword:`if` ਸਟੇਟਮੈਂਟ ਦੀ " "ਸ਼ਾਖਾ ਵਿੱਚ ਜਾਂ ਕਿਸੇ ਫੰਕਸ਼ਨ ਦੇ ਅੰਦਰ ਇੱਕ ਕਲਾਸ ਪਰਿਭਾਸ਼ਾ ਰੱਖ ਸਕਦੇ ਹੋ।)" msgid "" "In practice, the statements inside a class definition will usually be " "function definitions, but other statements are allowed, and sometimes useful " "--- we'll come back to this later. The function definitions inside a class " "normally have a peculiar form of argument list, dictated by the calling " "conventions for methods --- again, this is explained later." msgstr "" "ਅਮਲ ਵਿੱਚ, ਕਲਾਸ ਪਰਿਭਾਸ਼ਾ ਦੇ ਅੰਦਰਲੇ ਸਟੇਟਮੈਂਟ ਆਮ ਤੌਰ 'ਤੇ ਫੰਕਸ਼ਨ ਪਰਿਭਾਸ਼ਾਵਾਂ ਹੁੰਦੀਆਂ ਹਨ, ਪਰ ਹੋਰ " "ਸਟੇਟਮੈਂਟ ਵੀ ਮਨਜ਼ੂਰ ਹਨ ਅਤੇ ਕਈ ਵਾਰ ਲਾਭਦਾਇਕ ਵੀ ਹੁੰਦੀਆਂ ਹਨ — ਇਸ ਬਾਰੇ ਅਸੀਂ ਬਾਅਦ ਵਿੱਚ ਮੁੜ ਗੱਲ " "ਕਰਾਂਗੇ। ਕਲਾਸ ਦੇ ਅੰਦਰਲੇ ਫੰਕਸ਼ਨ ਆਮ ਤੌਰ 'ਤੇ ਆਰਗੂਮੈਂਟ ਸੂਚੀ ਦੇ ਇੱਕ ਵਿਸ਼ੇਸ਼ ਰੂਪ ਦੀ ਵਰਤੋਂ ਕਰਦੇ ਹਨ, ਜੋ " "ਵਿਧੀਆਂ ਦੀ ਕਾਲਿੰਗ ਪਰੰਪਰਾ ਦੁਆਰਾ ਨਿਰਧਾਰਤ ਹੁੰਦਾ ਹੈ — ਇਸਦੀ ਵੀ ਵਿਆਖਿਆ ਅੱਗੇ ਕੀਤੀ ਜਾਵੇਗੀ।" msgid "" "When a class definition is entered, a new namespace is created, and used as " "the local scope --- thus, all assignments to local variables go into this " "new namespace. In particular, function definitions bind the name of the new " "function here." msgstr "" "ਜਦੋਂ ਕਿਸੇ ਕਲਾਸ ਪਰਿਭਾਸ਼ਾ ਵਿੱਚ ਦਾਖਲ ਹੁੰਦੇ ਹਾਂ, ਤਾਂ ਇੱਕ ਨਵਾਂ ਨੇਮਸਪੇਸ ਬਣਾਇਆ ਜਾਂਦਾ ਹੈ ਅਤੇ ਇਸਨੂੰ " "ਸਥਾਨਕ ਸਕੋਪ ਵਜੋਂ ਵਰਤਿਆ ਜਾਂਦਾ ਹੈ। ਇਸ ਲਈ ਸਥਾਨਕ ਵੇਰੀਏਬਲਾਂ ਨੂੰ ਕੀਤੀਆਂ ਸਾਰੀਆਂ ਅਸਾਈਨਮੈਂਟਾਂ ਇਸ ਨਵੇਂ " "ਨੇਮਸਪੇਸ ਵਿੱਚ ਜਾਂਦੀਆਂ ਹਨ।" msgid "" "When a class definition is left normally (via the end), a *class object* is " "created. This is basically a wrapper around the contents of the namespace " "created by the class definition; we'll learn more about class objects in the " "next section. The original local scope (the one in effect just before the " "class definition was entered) is reinstated, and the class object is bound " "here to the class name given in the class definition header (:class:`!" "ClassName` in the example)." msgstr "" "ਜਦੋਂ ਕਲਾਸ ਪਰਿਭਾਸ਼ਾ ਆਮ ਤਰੀਕੇ ਨਾਲ (ਅੰਤ ਤੱਕ ਪਹੁੰਚ ਕੇ) ਸਮਾਪਤ ਹੁੰਦੀ ਹੈ, ਤਾਂ ਇੱਕ *ਕਲਾਸ ਆਬਜੈਕਟ* " "ਬਣਾਇਆ ਜਾਂਦਾ ਹੈ। ਇਹ ਅਸਲ ਵਿੱਚ ਕਲਾਸ ਪਰਿਭਾਸ਼ਾ ਦੁਆਰਾ ਬਣਾਏ ਗਏ ਨੇਮਸਪੇਸ ਦੀ ਸਮੱਗਰੀ ਦੇ ਆਲੇ-ਦੁਆਲੇ " "ਇੱਕ ਰੈਪਰ ਹੁੰਦਾ ਹੈ। ਅਗਲੇ ਭਾਗ ਵਿੱਚ ਅਸੀਂ ਕਲਾਸ ਆਬਜੈਕਟਾਂ ਬਾਰੇ ਹੋਰ ਸਿੱਖਾਂਗੇ। ਮੂਲ ਸਥਾਨਕ ਸਕੋਪ (ਜੋ ਕਲਾਸ " "ਪਰਿਭਾਸ਼ਾ ਵਿੱਚ ਦਾਖਲ ਹੋਣ ਤੋਂ ਠੀਕ ਪਹਿਲਾਂ ਸਰਗਰਮ ਸੀ) ਮੁੜ ਬਹਾਲ ਕੀਤਾ ਜਾਂਦਾ ਹੈ ਅਤੇ ਕਲਾਸ ਆਬਜੈਕਟ " "ਨੂੰ ਕਲਾਸ ਪਰਿਭਾਸ਼ਾ ਦੇ ਸਿਰਲੇਖ ਵਿੱਚ ਦਿੱਤੇ ਕਲਾਸ ਨਾਂ ਨਾਲ ਇੱਥੇ ਜੋੜਿਆ ਜਾਂਦਾ ਹੈ (:class:`!" "ClassName` ਉਦਾਹਰਨ ਵਿੱਚ)।" msgid "Class Objects" msgstr "ਕਲਾਸ ਆਬਜੈਕਟ" msgid "" "Class objects support two kinds of operations: attribute references and " "instantiation." msgstr "" "ਕਲਾਸ ਆਬਜੈਕਟ ਦੋ ਕਿਸਮ ਦੀਆਂ ਕਾਰਵਾਈਆਂ ਦਾ ਸਮਰਥਨ ਕਰਦੇ ਹਨ: ਐਟ੍ਰਿਬਿਊਟ ਹਵਾਲੇ ਅਤੇ ਇੰਸਟੈਂਸ਼ੀਏਸ਼ਨ।" msgid "" "*Attribute references* use the standard syntax used for all attribute " "references in Python: ``obj.name``. Valid attribute names are all the names " "that were in the class's namespace when the class object was created. So, " "if the class definition looked like this::" msgstr "" "*ਐਟ੍ਰਿਬਿਊਟ ਹਵਾਲੇ* Python ਵਿੱਚ ਸਾਰੇ ਐਟ੍ਰਿਬਿਊਟ ਹਵਾਲਿਆਂ ਲਈ ਵਰਤੇ ਜਾਣ ਵਾਲੇ ਮਿਆਰੀ ਸਿੰਟੈਕਸ " "``obj.name`` ਦੀ ਵਰਤੋਂ ਕਰਦੇ ਹਨ। ਵੈਧ ਐਟ੍ਰਿਬਿਊਟ ਨਾਂ ਉਹ ਸਾਰੇ ਨਾਂ ਹੁੰਦੇ ਹਨ ਜੋ ਕਲਾਸ ਆਬਜੈਕਟ " "ਬਣਾਉਣ ਵੇਲੇ ਕਲਾਸ ਦੇ ਨੇਮਸਪੇਸ ਵਿੱਚ ਮੌਜੂਦ ਸਨ। ਇਸ ਲਈ, ਜੇ ਕਲਾਸ ਪਰਿਭਾਸ਼ਾ ਇਸ ਤਰ੍ਹਾਂ ਹੋਵੇ::" msgid "" "class MyClass:\n" " \"\"\"A simple example class\"\"\"\n" " i = 12345\n" "\n" " def f(self):\n" " return 'hello world'" msgstr "" "class MyClass:\n" " \"\"\"ਇੱਕ ਸਰਲ ਉਦਾਹਰਨ ਕਲਾਸ\"\"\"\n" " i = 12345\n" "\n" " def f(self):\n" " return 'hello world'" msgid "" "then ``MyClass.i`` and ``MyClass.f`` are valid attribute references, " "returning an integer and a function object, respectively. Class attributes " "can also be assigned to, so you can change the value of ``MyClass.i`` by " "assignment. :attr:`~type.__doc__` is also a valid attribute, returning the " "docstring belonging to the class: ``\"A simple example class\"``." msgstr "" "ਤਾਂ ``MyClass.i`` ਅਤੇ ``MyClass.f`` ਵੈਧ ਐਟ੍ਰਿਬਿਊਟ ਹਵਾਲੇ ਹਨ, ਜੋ ਕ੍ਰਮਵਾਰ ਇੱਕ ਪੂਰਨ ਅੰਕ ਅਤੇ " "ਇੱਕ ਫੰਕਸ਼ਨ ਵਸਤੂ ਵਾਪਸ ਕਰਦੇ ਹਨ। ਕਲਾਸ ਐਟ੍ਰਿਬਿਊਟਾਂ ਨੂੰ ਅਸਾਈਨ ਵੀ ਕੀਤਾ ਜਾ ਸਕਦਾ ਹੈ, ਇਸ ਲਈ ਤੁਸੀਂ " "ਅਸਾਈਨਮੈਂਟ ਰਾਹੀਂ ``MyClass.i`` ਦਾ ਮੁੱਲ ਬਦਲ ਸਕਦੇ ਹੋ। :attr:`~type.__doc__` ਵੀ ਇੱਕ ਵੈਧ " "ਐਟ੍ਰਿਬਿਊਟ ਹੈ ਜੋ ਕਲਾਸ ਨਾਲ ਸੰਬੰਧਿਤ ਡਾਕਸਟਰਿੰਗ ``\"A simple example class\"`` ਵਾਪਸ " "ਕਰਦਾ ਹੈ।" msgid "" "Class *instantiation* uses function notation. Just pretend that the class " "object is a parameterless function that returns a new instance of the class. " "For example (assuming the above class)::" msgstr "" "ਕਲਾਸ *ਇੰਸਟੈਂਸ਼ੀਏਸ਼ਨ* ਫੰਕਸ਼ਨ ਨੋਟੇਸ਼ਨ ਦੀ ਵਰਤੋਂ ਕਰਦੀ ਹੈ। ਸਿਰਫ਼ ਇਹ ਮੰਨ ਲਵੋ ਕਿ ਕਲਾਸ ਆਬਜੈਕਟ ਇੱਕ ਬਿਨਾਂ " "ਪੈਰਾਮੀਟਰ ਵਾਲਾ ਫੰਕਸ਼ਨ ਹੈ ਜੋ ਕਲਾਸ ਦਾ ਨਵਾਂ ਇੰਸਟੈਂਸ ਵਾਪਸ ਕਰਦਾ ਹੈ। ਉਦਾਹਰਨ ਲਈ (ਉਪਰੋਕਤ ਕਲਾਸ " "ਮੰਨਦੇ ਹੋਏ)::" msgid "x = MyClass()" msgstr "x = MyClass()" msgid "" "creates a new *instance* of the class and assigns this object to the local " "variable ``x``." msgstr "" "ਇਹ ਕਲਾਸ ਦਾ ਇੱਕ ਨਵਾਂ *ਇੰਸਟੈਂਸ* ਬਣਾਉਂਦਾ ਹੈ ਅਤੇ ਇਸ ਵਸਤੂ ਨੂੰ ਸਥਾਨਕ ਵੇਰੀਏਬਲ ``x`` ਨਾਲ ਜੋੜ ਦਿੰਦਾ " "ਹੈ।" msgid "" "The instantiation operation (\"calling\" a class object) creates an empty " "object. Many classes like to create objects with instances customized to a " "specific initial state. Therefore a class may define a special method " "named :meth:`~object.__init__`, like this::" msgstr "" "ਇੰਸਟੈਂਸ਼ੀਏਸ਼ਨ ਕਾਰਵਾਈ (ਕਲਾਸ ਆਬਜੈਕਟ ਨੂੰ \"ਕਾਲ\" ਕਰਨਾ) ਇੱਕ ਖਾਲੀ ਆਬਜੈਕਟ ਬਣਾਉਂਦੀ ਹੈ। ਬਹੁਤ " "ਸਾਰੀਆਂ ਕਲਾਸਾਂ ਐਸੀਆਂ ਵਸਤੂਆਂ ਬਣਾਉਣਾ ਪਸੰਦ ਕਰਦੀਆਂ ਹਨ ਜਿਨ੍ਹਾਂ ਦੇ ਇੰਸਟੈਂਸ ਕਿਸੇ ਖਾਸ ਸ਼ੁਰੂਆਤੀ ਸਥਿਤੀ " "ਅਨੁਸਾਰ ਸੰਰਚਿਤ ਕੀਤੇ ਗਏ ਹੋਣ। ਇਸ ਲਈ ਕੋਈ ਕਲਾਸ :meth:`~object.__init__` ਨਾਂ ਦੀ ਇੱਕ ਵਿਸ਼ੇਸ਼ " "ਵਿਧੀ ਪਰਿਭਾਸ਼ਿਤ ਕਰ ਸਕਦੀ ਹੈ, ਜਿਵੇਂ ਕਿ::" msgid "" "def __init__(self):\n" " self.data = []" msgstr "" "def __init__(self):\n" " self.data = []" msgid "" "When a class defines an :meth:`~object.__init__` method, class instantiation " "automatically invokes :meth:`!__init__` for the newly created class " "instance. So in this example, a new, initialized instance can be obtained " "by::" msgstr "" "ਜਦੋਂ ਕੋਈ ਕਲਾਸ :meth:`~object.__init__` ਵਿਧੀ ਪਰਿਭਾਸ਼ਿਤ ਕਰਦੀ ਹੈ, ਤਾਂ ਕਲਾਸ ਇੰਸਟੈਂਸ਼ੀਏਸ਼ਨ " "ਨਵੇਂ ਬਣੇ ਕਲਾਸ ਇੰਸਟੈਂਸ ਲਈ ਆਪਣੇ ਆਪ :meth:`!__init__` ਨੂੰ ਚਲਾਉਂਦੀ ਹੈ। ਇਸ ਉਦਾਹਰਨ ਵਿੱਚ ਇੱਕ ਨਵਾਂ " "ਅਤੇ ਸ਼ੁਰੂਆਤੀਕ੍ਰਿਤ ਇੰਸਟੈਂਸ ਇਸ ਤਰ੍ਹਾਂ ਪ੍ਰਾਪਤ ਕੀਤਾ ਜਾ ਸਕਦਾ ਹੈ::" msgid "" "Of course, the :meth:`~object.__init__` method may have arguments for " "greater flexibility. In that case, arguments given to the class " "instantiation operator are passed on to :meth:`!__init__`. For example, ::" msgstr "" "ਬੇਸ਼ੱਕ, ਵੱਧ ਲਚਕਤਾ ਲਈ :meth:`~object.__init__` ਵਿਧੀ ਵਿੱਚ ਆਰਗੂਮੈਂਟ ਹੋ ਸਕਦੇ ਹਨ। ਇਸ ਸਥਿਤੀ " "ਵਿੱਚ ਕਲਾਸ ਇੰਸਟੈਂਸ਼ੀਏਸ਼ਨ ਓਪਰੇਟਰ ਨੂੰ ਦਿੱਤੇ ਗਏ ਆਰਗੂਮੈਂਟ :meth:`!__init__` ਨੂੰ ਭੇਜੇ ਜਾਂਦੇ ਹਨ। ਉਦਾਹਰਨ " "ਲਈ::" msgid "" ">>> class Complex:\n" "... def __init__(self, realpart, imagpart):\n" "... self.r = realpart\n" "... self.i = imagpart\n" "...\n" ">>> x = Complex(3.0, -4.5)\n" ">>> x.r, x.i\n" "(3.0, -4.5)" msgstr "" ">>> class Complex:\n" "... def __init__(self, realpart, imagpart):\n" "... self.r = realpart\n" "... self.i = imagpart\n" "...\n" ">>> x = Complex(3.0, -4.5)\n" ">>> x.r, x.i\n" "(3.0, -4.5)" msgid "Instance Objects" msgstr "ਇੰਸਟੈਂਸ ਆਬਜੈਕਟ" msgid "" "Now what can we do with instance objects? The only operations understood by " "instance objects are attribute references. There are two kinds of valid " "attribute names: data attributes and methods." msgstr "" "ਹੁਣ ਅਸੀਂ ਇੰਸਟੈਂਸ ਆਬਜੈਕਟਾਂ ਨਾਲ ਕੀ ਕਰ ਸਕਦੇ ਹਾਂ? ਇੰਸਟੈਂਸ ਆਬਜੈਕਟਾਂ ਦੁਆਰਾ ਸਮਝੀ ਜਾਣ ਵਾਲੀ ਇਕੱਲੀ " "ਕਾਰਵਾਈ ਐਟ੍ਰਿਬਿਊਟ ਹਵਾਲਾ ਹੈ। ਵੈਧ ਐਟ੍ਰਿਬਿਊਟ ਨਾਂਵਾਂ ਦੀਆਂ ਦੋ ਕਿਸਮਾਂ ਹਨ: data attributes ਅਤੇ " "methods।" msgid "" "*Data attributes* correspond to \"instance variables\" in Smalltalk, and to " "\"data members\" in C++. Data attributes need not be declared; like local " "variables, they spring into existence when they are first assigned to. For " "example, if ``x`` is the instance of :class:`!MyClass` created above, the " "following piece of code will print the value ``16``, without leaving a " "trace::" msgstr "" "*ਡਾਟਾ ਐਟ੍ਰਿਬਿਊਟ* Smalltalk ਵਿੱਚ \"instance variables\" ਅਤੇ C++ ਵਿੱਚ \"data " "members\" ਦੇ ਸਮਾਨ ਹੁੰਦੇ ਹਨ। ਡਾਟਾ ਐਟ੍ਰਿਬਿਊਟਾਂ ਨੂੰ ਪਹਿਲਾਂ ਤੋਂ ਘੋਸ਼ਿਤ ਕਰਨ ਦੀ ਲੋੜ ਨਹੀਂ ਹੁੰਦੀ; " "ਸਥਾਨਕ ਵੇਰੀਏਬਲਾਂ ਵਾਂਗ ਇਹ ਪਹਿਲੀ ਵਾਰ ਅਸਾਈਨ ਹੋਣ 'ਤੇ ਮੌਜੂਦਗੀ ਵਿੱਚ ਆ ਜਾਂਦੇ ਹਨ। ਉਦਾਹਰਨ ਵਜੋਂ, ਜੇ " "``x`` ਉੱਪਰ ਬਣਾਇਆ ਗਿਆ :class:`!MyClass` ਦਾ ਇੰਸਟੈਂਸ ਹੈ, ਤਾਂ ਹੇਠਾਂ ਦਿੱਤਾ ਕੋਡ ``16`` ਮੁੱਲ " "ਪ੍ਰਿੰਟ ਕਰੇਗਾ ਅਤੇ ਬਾਅਦ ਵਿੱਚ ਕੋਈ ਨਿਸ਼ਾਨ ਨਹੀਂ ਛੱਡੇਗਾ::" msgid "" "x.counter = 1\n" "while x.counter < 10:\n" " x.counter = x.counter * 2\n" "print(x.counter)\n" "del x.counter" msgstr "" "x.counter = 1\n" "while x.counter < 10:\n" " x.counter = x.counter * 2\n" "print(x.counter)\n" "del x.counter" msgid "" "The other kind of instance attribute reference is a *method*. A method is a " "function that \"belongs to\" an object." msgstr "" "ਇੰਸਟੈਂਸ ਐਟ੍ਰਿਬਿਊਟ ਹਵਾਲੇ ਦੀ ਦੂਜੀ ਕਿਸਮ *method* ਹੈ। Method ਇੱਕ ਐਸਾ ਫੰਕਸ਼ਨ ਹੈ ਜੋ ਕਿਸੇ ਆਬਜੈਕਟ " "ਨਾਲ ਸੰਬੰਧਿਤ ਹੁੰਦਾ ਹੈ।" msgid "" "Valid method names of an instance object depend on its class. By " "definition, all attributes of a class that are function objects define " "corresponding methods of its instances. So in our example, ``x.f`` is a " "valid method reference, since ``MyClass.f`` is a function, but ``x.i`` is " "not, since ``MyClass.i`` is not. But ``x.f`` is not the same thing as " "``MyClass.f`` --- it is a *method object*, not a function object." msgstr "" "ਕਿਸੇ ਇੰਸਟੈਂਸ ਆਬਜੈਕਟ ਦੇ ਵੈਧ ਮੈਥਡ ਨਾਮ ਉਸਦੀ ਕਲਾਸ 'ਤੇ ਨਿਰਭਰ ਕਰਦੇ ਹਨ। ਪਰਿਭਾਸ਼ਾ ਅਨੁਸਾਰ, ਕਲਾਸ ਦੇ " "ਉਹ ਸਾਰੇ ਐਟ੍ਰਿਬਿਊਟ ਜੋ ਫੰਕਸ਼ਨ ਆਬਜੈਕਟ ਹੁੰਦੇ ਹਨ, ਉਸਦੇ ਇੰਸਟੈਂਸਾਂ ਲਈ ਸੰਬੰਧਿਤ ਮੈਥਡ ਪਰਿਭਾਸ਼ਿਤ ਕਰਦੇ ਹਨ। " "ਇਸ ਲਈ ਸਾਡੀ ਉਦਾਹਰਨ ਵਿੱਚ ``x.f`` ਇੱਕ ਵੈਧ ਮੈਥਡ ਹਵਾਲਾ ਹੈ, ਕਿਉਂਕਿ ``MyClass.f`` ਇੱਕ ਫੰਕਸ਼ਨ " "ਹੈ, ਪਰ ``x.i`` ਨਹੀਂ, ਕਿਉਂਕਿ ``MyClass.i`` ਨਹੀਂ ਹੈ। ਪਰ ``x.f`` ``MyClass.f`` ਦੇ " "ਸਮਾਨ ਨਹੀਂ ਹੈ — ਇਹ ਇੱਕ *ਮੈਥਡ ਆਬਜੈਕਟ* ਹੈ, ਫੰਕਸ਼ਨ ਆਬਜੈਕਟ ਨਹੀਂ।" msgid "Method Objects" msgstr "Method Objects" msgid "Usually, a method is called right after it is bound::" msgstr "ਆਮ ਤੌਰ 'ਤੇ, ਕਿਸੇ method ਨੂੰ ਉਸਦੇ bind ਹੋਣ ਦੇ ਤੁਰੰਤ ਬਾਅਦ call ਕੀਤਾ ਜਾਂਦਾ ਹੈ::" msgid "x.f()" msgstr "x.f()" msgid "" "If ``x = MyClass()``, as above, this will return the string ``'hello " "world'``. However, it is not necessary to call a method right away: ``x.f`` " "is a method object, and can be stored away and called at a later time. For " "example::" msgstr "" "ਜੇ ਉੱਪਰ ਵਾਂਗ ``x = MyClass()`` ਹੋਵੇ, ਤਾਂ ਇਹ ``'hello world'`` ਸਟ੍ਰਿੰਗ ਵਾਪਸ ਕਰੇਗਾ। ਪਰ " "ਮੈਥਡ ਨੂੰ ਤੁਰੰਤ ਕਾਲ ਕਰਨਾ ਲਾਜ਼ਮੀ ਨਹੀਂ ਹੈ। ``x.f`` ਇੱਕ ਮੈਥਡ ਆਬਜੈਕਟ ਹੈ ਅਤੇ ਇਸਨੂੰ ਸੰਭਾਲ ਕੇ ਬਾਅਦ " "ਵਿੱਚ ਵੀ ਕਾਲ ਕੀਤਾ ਜਾ ਸਕਦਾ ਹੈ। ਉਦਾਹਰਨ ਲਈ::" msgid "" "xf = x.f\n" "while True:\n" " print(xf())" msgstr "" "xf = x.f\n" "while True:\n" " print(xf())" msgid "will continue to print ``hello world`` until the end of time." msgstr "ਇਹ ਅਨੰਤ ਸਮੇਂ ਤੱਕ ``hello world`` ਪ੍ਰਿੰਟ ਕਰਦਾ ਰਹੇਗਾ।" msgid "" "What exactly happens when a method is called? You may have noticed that " "``x.f()`` was called without an argument above, even though the function " "definition for :meth:`!f` specified an argument. What happened to the " "argument? Surely Python raises an exception when a function that requires an " "argument is called without any --- even if the argument isn't actually " "used..." msgstr "" "ਜਦੋਂ ਕੋਈ ਮੈਥਡ ਕਾਲ ਕੀਤਾ ਜਾਂਦਾ ਹੈ ਤਾਂ ਅਸਲ ਵਿੱਚ ਕੀ ਹੁੰਦਾ ਹੈ? ਤੁਸੀਂ ਧਿਆਨ ਦਿੱਤਾ ਹੋਵੇਗਾ ਕਿ ਉੱਪਰ " "``x.f()`` ਬਿਨਾਂ ਕਿਸੇ ਆਰਗੂਮੈਂਟ ਦੇ ਕਾਲ ਕੀਤਾ ਗਿਆ ਸੀ, ਹਾਲਾਂਕਿ :meth:`!f` ਦੀ ਪਰਿਭਾਸ਼ਾ ਵਿੱਚ " "ਇੱਕ ਆਰਗੂਮੈਂਟ ਦਿੱਤਾ ਗਿਆ ਸੀ। ਫਿਰ ਉਹ ਆਰਗੂਮੈਂਟ ਕਿੱਥੇ ਗਿਆ? ਆਮ ਤੌਰ 'ਤੇ Python ਉਸ ਵੇਲੇ ਐਕਸੈਪਸ਼ਨ ਪੈਦਾ " "ਕਰਦਾ ਹੈ ਜਦੋਂ ਕਿਸੇ ਲੋੜੀਂਦੇ ਆਰਗੂਮੈਂਟ ਵਾਲੇ ਫੰਕਸ਼ਨ ਨੂੰ ਬਿਨਾਂ ਆਰਗੂਮੈਂਟ ਦੇ ਕਾਲ ਕੀਤਾ ਜਾਵੇ — ਭਾਵੇਂ ਉਹ ਆਰਗੂਮੈਂਟ " "ਵਰਤਿਆ ਨਾ ਵੀ ਜਾਵੇ..." msgid "" "Actually, you may have guessed the answer: the special thing about methods " "is that the instance object is passed as the first argument of the " "function. In our example, the call ``x.f()`` is exactly equivalent to " "``MyClass.f(x)``. In general, calling a method with a list of *n* arguments " "is equivalent to calling the corresponding function with an argument list " "that is created by inserting the method's instance object before the first " "argument." msgstr "" "ਅਸਲ ਵਿੱਚ, ਤੁਸੀਂ ਸ਼ਾਇਦ ਇਸਦਾ ਜਵਾਬ ਅੰਦਾਜ਼ਾ ਲਾ ਲਿਆ ਹੋਵੇਗਾ। ਮੈਥਡਾਂ ਦੀ ਖਾਸ ਗੱਲ ਇਹ ਹੈ ਕਿ ਇੰਸਟੈਂਸ " "ਆਬਜੈਕਟ ਆਪਣੇ ਆਪ ਫੰਕਸ਼ਨ ਦੇ ਪਹਿਲੇ ਆਰਗੂਮੈਂਟ ਵਜੋਂ ਭੇਜਿਆ ਜਾਂਦਾ ਹੈ। ਸਾਡੀ ਉਦਾਹਰਨ ਵਿੱਚ ``x.f()`` ਦੀ " "ਕਾਲ ਬਿਲਕੁਲ ``MyClass.f(x)`` ਦੇ ਬਰਾਬਰ ਹੈ। ਆਮ ਤੌਰ 'ਤੇ, *n* ਆਰਗੂਮੈਂਟਾਂ ਵਾਲੇ ਮੈਥਡ ਨੂੰ ਕਾਲ " "ਕਰਨਾ ਉਸ ਸੰਬੰਧਿਤ ਫੰਕਸ਼ਨ ਨੂੰ ਕਾਲ ਕਰਨ ਦੇ ਬਰਾਬਰ ਹੈ ਜਿਸਦੇ ਆਰਗੂਮੈਂਟਾਂ ਦੀ ਸੂਚੀ ਦੇ ਸ਼ੁਰੂ ਵਿੱਚ ਇੰਸਟੈਂਸ " "ਆਬਜੈਕਟ ਜੋੜਿਆ ਗਿਆ ਹੋਵੇ।" msgid "" "In general, methods work as follows. When a non-data attribute of an " "instance is referenced, the instance's class is searched. If the name " "denotes a valid class attribute that is a function object, references to " "both the instance object and the function object are packed into a method " "object. When the method object is called with an argument list, a new " "argument list is constructed from the instance object and the argument list, " "and the function object is called with this new argument list." msgstr "" "ਆਮ ਤੌਰ 'ਤੇ ਮੈਥਡ ਇਸ ਤਰ੍ਹਾਂ ਕੰਮ ਕਰਦੇ ਹਨ। ਜਦੋਂ ਕਿਸੇ ਇੰਸਟੈਂਸ ਦੇ ਗੈਰ-ਡਾਟਾ ਐਟ੍ਰਿਬਿਊਟ ਦਾ ਹਵਾਲਾ ਦਿੱਤਾ " "ਜਾਂਦਾ ਹੈ, ਤਾਂ ਉਸਦੀ ਕਲਾਸ ਵਿੱਚ ਖੋਜ ਕੀਤੀ ਜਾਂਦੀ ਹੈ। ਜੇਕਰ ਉਹ ਨਾਮ ਕਿਸੇ ਐਸੇ ਕਲਾਸ ਐਟ੍ਰਿਬਿਊਟ ਨੂੰ " "ਦਰਸਾਉਂਦਾ ਹੋਵੇ ਜੋ ਇੱਕ ਫੰਕਸ਼ਨ ਆਬਜੈਕਟ ਹੈ, ਤਾਂ ਇੰਸਟੈਂਸ ਆਬਜੈਕਟ ਅਤੇ ਫੰਕਸ਼ਨ ਆਬਜੈਕਟ ਦੋਵਾਂ ਦੇ ਹਵਾਲੇ ਮਿਲਾ ਕੇ " "ਇੱਕ ਮੈਥਡ ਆਬਜੈਕਟ ਬਣਾਇਆ ਜਾਂਦਾ ਹੈ। ਜਦੋਂ ਇਸ ਮੈਥਡ ਆਬਜੈਕਟ ਨੂੰ ਆਰਗੂਮੈਂਟਾਂ ਨਾਲ ਕਾਲ ਕੀਤਾ ਜਾਂਦਾ ਹੈ, ਤਾਂ " "ਇੰਸਟੈਂਸ ਆਬਜੈਕਟ ਅਤੇ ਦਿੱਤੇ ਗਏ ਆਰਗੂਮੈਂਟਾਂ ਤੋਂ ਇੱਕ ਨਵੀਂ ਆਰਗੂਮੈਂਟ ਸੂਚੀ ਬਣਾਈ ਜਾਂਦੀ ਹੈ ਅਤੇ ਫੰਕਸ਼ਨ ਆਬਜੈਕਟ ਨੂੰ " "ਇਸ ਨਵੀਂ ਸੂਚੀ ਨਾਲ ਕਾਲ ਕੀਤਾ ਜਾਂਦਾ ਹੈ।" msgid "Class and Instance Variables" msgstr "ਕਲਾਸ ਅਤੇ ਇੰਸਟੈਂਸ ਵੇਰੀਏਬਲ" msgid "" "Generally speaking, instance variables are for data unique to each instance " "and class variables are for attributes and methods shared by all instances " "of the class::" msgstr "" "ਆਮ ਤੌਰ 'ਤੇ, ਇੰਸਟੈਂਸ ਵੇਰੀਏਬਲ ਹਰ ਇੰਸਟੈਂਸ ਲਈ ਵਿਲੱਖਣ ਡਾਟਾ ਸੰਭਾਲਣ ਲਈ ਹੁੰਦੇ ਹਨ ਅਤੇ ਕਲਾਸ ਵੇਰੀਏਬਲ " "ਉਹਨਾਂ ਐਟ੍ਰਿਬਿਊਟਾਂ ਅਤੇ ਵਿਧੀਆਂ ਲਈ ਹੁੰਦੇ ਹਨ ਜੋ ਕਲਾਸ ਦੇ ਸਾਰੇ ਇੰਸਟੈਂਸਾਂ ਦੁਆਰਾ ਸਾਂਝੇ ਕੀਤੇ ਜਾਂਦੇ ਹਨ::" msgid "" "class Dog:\n" "\n" " kind = 'canine' # class variable shared by all instances\n" "\n" " def __init__(self, name):\n" " self.name = name # instance variable unique to each instance\n" "\n" ">>> d = Dog('Fido')\n" ">>> e = Dog('Buddy')\n" ">>> d.kind # shared by all dogs\n" "'canine'\n" ">>> e.kind # shared by all dogs\n" "'canine'\n" ">>> d.name # unique to d\n" "'Fido'\n" ">>> e.name # unique to e\n" "'Buddy'" msgstr "" "class Dog:\n" "\n" " kind = 'canine' # class variable shared by all instances\n" "\n" " def __init__(self, name):\n" " self.name = name # instance variable unique to each instance\n" "\n" ">>> d = Dog('Fido')\n" ">>> e = Dog('Buddy')\n" ">>> d.kind # shared by all dogs\n" "'canine'\n" ">>> e.kind # shared by all dogs\n" "'canine'\n" ">>> d.name # unique to d\n" "'Fido'\n" ">>> e.name # unique to e\n" "'Buddy'" msgid "" "As discussed in :ref:`tut-object`, shared data can have possibly surprising " "effects involving :term:`mutable` objects such as lists and dictionaries. " "For example, the *tricks* list in the following code should not be used as a " "class variable because just a single list would be shared by all *Dog* " "instances::" msgstr "" "ਜਿਵੇਂ ਕਿ :ref:`tut-object` ਵਿੱਚ ਚਰਚਾ ਕੀਤੀ ਗਈ ਹੈ, ਸਾਂਝਾ ਡਾਟਾ :term:`mutable` " "ਆਬਜੈਕਟਾਂ ਜਿਵੇਂ ਲਿਸਟਾਂ ਅਤੇ ਡਿਕਸ਼ਨਰੀਆਂ ਨਾਲ ਕਈ ਵਾਰ ਹੈਰਾਨੀਜਨਕ ਨਤੀਜੇ ਪੈਦਾ ਕਰ ਸਕਦਾ ਹੈ। ਉਦਾਹਰਨ " "ਵਜੋਂ, ਹੇਠਾਂ ਦਿੱਤੇ ਕੋਡ ਵਿੱਚ *tricks* ਲਿਸਟ ਨੂੰ ਕਲਾਸ ਵੇਰੀਏਬਲ ਵਜੋਂ ਨਹੀਂ ਵਰਤਣਾ ਚਾਹੀਦਾ ਕਿਉਂਕਿ ਇੱਕੋ " "ਲਿਸਟ ਸਾਰੇ *Dog* ਇੰਸਟੈਂਸਾਂ ਵੱਲੋਂ ਸਾਂਝੀ ਕੀਤੀ ਜਾਵੇਗੀ::" msgid "" "class Dog:\n" "\n" " tricks = [] # mistaken use of a class variable\n" "\n" " def __init__(self, name):\n" " self.name = name\n" "\n" " def add_trick(self, trick):\n" " self.tricks.append(trick)\n" "\n" ">>> d = Dog('Fido')\n" ">>> e = Dog('Buddy')\n" ">>> d.add_trick('roll over')\n" ">>> e.add_trick('play dead')\n" ">>> d.tricks # unexpectedly shared by all dogs\n" "['roll over', 'play dead']" msgstr "" "class Dog:\n" "\n" " tricks = [] # mistaken use of a class variable\n" "\n" " def __init__(self, name):\n" " self.name = name\n" "\n" " def add_trick(self, trick):\n" " self.tricks.append(trick)\n" "\n" ">>> d = Dog('Fido')\n" ">>> e = Dog('Buddy')\n" ">>> d.add_trick('roll over')\n" ">>> e.add_trick('play dead')\n" ">>> d.tricks # unexpectedly shared by all dogs\n" "['roll over', 'play dead']" msgid "Correct design of the class should use an instance variable instead::" msgstr "ਕਲਾਸ ਦੇ ਸਹੀ ਡਿਜ਼ਾਇਨ ਵਿੱਚ ਇਸਦੀ ਬਜਾਏ ਇੱਕ ਇੰਸਟੈਂਸ ਵੇਰੀਏਬਲ ਵਰਤਣਾ ਚਾਹੀਦਾ ਹੈ::" msgid "" "class Dog:\n" "\n" " def __init__(self, name):\n" " self.name = name\n" " self.tricks = [] # creates a new empty list for each dog\n" "\n" " def add_trick(self, trick):\n" " self.tricks.append(trick)\n" "\n" ">>> d = Dog('Fido')\n" ">>> e = Dog('Buddy')\n" ">>> d.add_trick('roll over')\n" ">>> e.add_trick('play dead')\n" ">>> d.tricks\n" "['roll over']\n" ">>> e.tricks\n" "['play dead']" msgstr "" "class Dog:\n" "\n" " def __init__(self, name):\n" " self.name = name\n" " self.tricks = [] # creates a new empty list for each dog\n" "\n" " def add_trick(self, trick):\n" " self.tricks.append(trick)\n" "\n" ">>> d = Dog('Fido')\n" ">>> e = Dog('Buddy')\n" ">>> d.add_trick('roll over')\n" ">>> e.add_trick('play dead')\n" ">>> d.tricks\n" "['roll over']\n" ">>> e.tricks\n" "['play dead']" msgid "Random Remarks" msgstr "ਕੁਝ ਵਾਧੂ ਟਿੱਪਣੀਆਂ" msgid "" "If the same attribute name occurs in both an instance and in a class, then " "attribute lookup prioritizes the instance::" msgstr "" "ਜੇਕਰ ਇੱਕੋ ਐਟ੍ਰਿਬਿਊਟ ਨਾਂ ਇੰਸਟੈਂਸ ਅਤੇ ਕਲਾਸ ਦੋਵਾਂ ਵਿੱਚ ਮੌਜੂਦ ਹੋਵੇ, ਤਾਂ ਐਟ੍ਰਿਬਿਊਟ ਖੋਜ ਦੌਰਾਨ ਇੰਸਟੈਂਸ ਨੂੰ " "ਤਰਜੀਹ ਦਿੱਤੀ ਜਾਂਦੀ ਹੈ::" msgid "" ">>> class Warehouse:\n" "... purpose = 'storage'\n" "... region = 'west'\n" "...\n" ">>> w1 = Warehouse()\n" ">>> print(w1.purpose, w1.region)\n" "storage west\n" ">>> w2 = Warehouse()\n" ">>> w2.region = 'east'\n" ">>> print(w2.purpose, w2.region)\n" "storage east" msgstr "" ">>> class Warehouse:\n" "... purpose = 'storage'\n" "... region = 'west'\n" "...\n" ">>> w1 = Warehouse()\n" ">>> print(w1.purpose, w1.region)\n" "storage west\n" ">>> w2 = Warehouse()\n" ">>> w2.region = 'east'\n" ">>> print(w2.purpose, w2.region)\n" "storage east" msgid "" "Data attributes may be referenced by methods as well as by ordinary users " "(\"clients\") of an object. In other words, classes are not usable to " "implement pure abstract data types. In fact, nothing in Python makes it " "possible to enforce data hiding --- it is all based upon convention. (On " "the other hand, the Python implementation, written in C, can completely hide " "implementation details and control access to an object if necessary; this " "can be used by extensions to Python written in C.)" msgstr "" "ਡਾਟਾ ਐਟ੍ਰਿਬਿਊਟਾਂ ਨੂੰ ਵਿਧੀਆਂ ਅਤੇ ਕਿਸੇ ਵਸਤੂ ਦੇ ਆਮ ਵਰਤੋਂਕਾਰਾਂ (\"ਕਲਾਇੰਟਾਂ\") ਦੁਆਰਾ ਵੀ ਹਵਾਲਾ " "ਦਿੱਤਾ ਜਾ ਸਕਦਾ ਹੈ। ਦੂਜੇ ਸ਼ਬਦਾਂ ਵਿੱਚ, ਕਲਾਸਾਂ ਨੂੰ ਪੂਰੀ ਤਰ੍ਹਾਂ ਅਮੂਰਤ ਡਾਟਾ ਕਿਸਮਾਂ ਲਾਗੂ ਕਰਨ ਲਈ " "ਵਰਤਿਆ ਨਹੀਂ ਜਾ ਸਕਦਾ। ਅਸਲ ਵਿੱਚ Python ਵਿੱਚ ਡਾਟਾ ਲੁਕਾਉਣ ਨੂੰ ਲਾਜ਼ਮੀ ਬਣਾਉਣ ਦਾ ਕੋਈ ਤਰੀਕਾ " "ਨਹੀਂ ਹੈ — ਇਹ ਸਾਰਾ ਕੁਝ ਰਿਵਾਜਾਂ ਉੱਤੇ ਆਧਾਰਿਤ ਹੈ। (ਦੂਜੇ ਪਾਸੇ, C ਵਿੱਚ ਲਿਖਿਆ Python ਇੰਪਲੀਮੈਂਟੇਸ਼ਨ " "ਲੋੜ ਪੈਣ 'ਤੇ ਅੰਦਰੂਨੀ ਵੇਰਵਿਆਂ ਨੂੰ ਪੂਰੀ ਤਰ੍ਹਾਂ ਲੁਕਾ ਸਕਦਾ ਹੈ ਅਤੇ ਵਸਤੂ ਤੱਕ ਪਹੁੰਚ ਨੂੰ ਨਿਯੰਤਰਿਤ ਕਰ ਸਕਦਾ " "ਹੈ; ਇਹ C ਵਿੱਚ ਲਿਖੀਆਂ Python ਐਕਸਟੈਂਸ਼ਨਾਂ ਦੁਆਰਾ ਵਰਤਿਆ ਜਾ ਸਕਦਾ ਹੈ।)" msgid "" "Clients should use data attributes with care --- clients may mess up " "invariants maintained by the methods by stamping on their data attributes. " "Note that clients may add data attributes of their own to an instance object " "without affecting the validity of the methods, as long as name conflicts are " "avoided --- again, a naming convention can save a lot of headaches here." msgstr "" "Clients ਨੂੰ data attributes ਦੀ ਵਰਤੋਂ ਸਾਵਧਾਨੀ ਨਾਲ ਕਰਨੀ ਚਾਹੀਦੀ ਹੈ, ਕਿਉਂਕਿ ਉਹ ਆਪਣੇ " "attributes ਵਿੱਚ ਤਬਦੀਲੀਆਂ ਕਰਕੇ methods ਦੁਆਰਾ ਬਣਾਈ ਰੱਖੀਆਂ ਗਈਆਂ invariants ਨੂੰ ਖਰਾਬ ਕਰ " "ਸਕਦੇ ਹਨ। ਧਿਆਨ ਦਿਓ ਕਿ ਜੇ ਨਾਂਵਾਂ ਦਾ ਟਕਰਾਅ ਨਾ ਹੋਵੇ ਤਾਂ clients instance object ਵਿੱਚ ਆਪਣੇ " "data attributes ਵੀ ਜੋੜ ਸਕਦੇ ਹਨ ਬਿਨਾਂ methods ਦੀ ਵੈਧਤਾ ਨੂੰ ਪ੍ਰਭਾਵਿਤ ਕੀਤੇ। ਇੱਥੇ ਵੀ ਇੱਕ " "ਵਧੀਆ naming convention ਬਹੁਤ ਸਾਰੀਆਂ ਮੁਸ਼ਕਲਾਂ ਤੋਂ ਬਚਾ ਸਕਦਾ ਹੈ।" msgid "" "There is no shorthand for referencing data attributes (or other methods!) " "from within methods. I find that this actually increases the readability of " "methods: there is no chance of confusing local variables and instance " "variables when glancing through a method." msgstr "" "Methods ਦੇ ਅੰਦਰੋਂ data attributes (ਜਾਂ ਹੋਰ methods) ਦਾ ਹਵਾਲਾ ਦੇਣ ਲਈ ਕੋਈ ਸੰਖੇਪ ਰੂਪ ਨਹੀਂ " "ਹੈ। ਅਸਲ ਵਿੱਚ ਇਹ methods ਦੀ ਪੜ੍ਹਨਯੋਗਤਾ ਵਧਾਉਂਦਾ ਹੈ ਕਿਉਂਕਿ method ਨੂੰ ਦੇਖਦੇ ਸਮੇਂ local " "variables ਅਤੇ instance variables ਵਿੱਚ ਉਲਝਣ ਦੀ ਸੰਭਾਵਨਾ ਨਹੀਂ ਰਹਿੰਦੀ।" msgid "" "Often, the first argument of a method is called ``self``. This is nothing " "more than a convention: the name ``self`` has absolutely no special meaning " "to Python. Note, however, that by not following the convention your code " "may be less readable to other Python programmers, and it is also conceivable " "that a *class browser* program might be written that relies upon such a " "convention." msgstr "" "ਅਕਸਰ ਕਿਸੇ ਮੈਥਡ ਦੇ ਪਹਿਲੇ ਆਰਗੂਮੈਂਟ ਨੂੰ ``self`` ਕਿਹਾ ਜਾਂਦਾ ਹੈ। ਇਹ ਸਿਰਫ਼ ਇੱਕ ਰਿਵਾਜ ਹੈ; " "``self`` ਨਾਮ ਦਾ Python ਲਈ ਕੋਈ ਖਾਸ ਅਰਥ ਨਹੀਂ ਹੈ। ਹਾਲਾਂਕਿ, ਜੇ ਤੁਸੀਂ ਇਸ ਰਿਵਾਜ ਦੀ ਪਾਲਣਾ " "ਨਹੀਂ ਕਰਦੇ, ਤਾਂ ਤੁਹਾਡਾ ਕੋਡ ਹੋਰ Python ਪ੍ਰੋਗਰਾਮਰਾਂ ਲਈ ਘੱਟ ਸਮਝਣਯੋਗ ਹੋ ਸਕਦਾ ਹੈ ਅਤੇ ਸੰਭਵ ਹੈ ਕਿ ਕੋਈ " "*class browser* ਪ੍ਰੋਗਰਾਮ ਵੀ ਇਸੇ ਰਿਵਾਜ 'ਤੇ ਨਿਰਭਰ ਕਰਦਾ ਹੋਵੇ।" msgid "" "Any function object that is a class attribute defines a method for instances " "of that class. It is not necessary that the function definition is " "textually enclosed in the class definition: assigning a function object to a " "local variable in the class is also ok. For example::" msgstr "" "ਕਲਾਸ ਐਟ੍ਰਿਬਿਊਟ ਵਜੋਂ ਮੌਜੂਦ ਹਰ ਫੰਕਸ਼ਨ ਆਬਜੈਕਟ ਉਸ ਕਲਾਸ ਦੇ ਇੰਸਟੈਂਸਾਂ ਲਈ ਇੱਕ ਮੈਥਡ ਪਰਿਭਾਸ਼ਿਤ ਕਰਦਾ " "ਹੈ। ਇਹ ਲਾਜ਼ਮੀ ਨਹੀਂ ਕਿ ਫੰਕਸ਼ਨ ਦੀ ਪਰਿਭਾਸ਼ਾ ਪਾਠਕ ਰੂਪ ਵਿੱਚ ਕਲਾਸ ਪਰਿਭਾਸ਼ਾ ਦੇ ਅੰਦਰ ਹੀ ਹੋਵੇ; " "ਕਲਾਸ ਦੇ ਅੰਦਰ ਕਿਸੇ ਫੰਕਸ਼ਨ ਆਬਜੈਕਟ ਨੂੰ ਸਥਾਨਕ ਵੇਰੀਏਬਲ ਨਾਲ ਜੋੜਨਾ ਵੀ ਠੀਕ ਹੈ। ਉਦਾਹਰਨ ਲਈ::" msgid "" "# Function defined outside the class\n" "def f1(self, x, y):\n" " return min(x, x+y)\n" "\n" "class C:\n" " f = f1\n" "\n" |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |