Friendly tracebacks - בעברית ====================================== Friendly שואפת לספק משוב ידידותי יותר כאשר מדובר בחריג מוגדל ממה שנעשה על ידי Python. (sentence translated by Google Translate). Below, we can find some examples. SyntaxError cases, as well as TabError and IndentationError cases, are shown in a separate page. Not all cases handled by friendly are included here. .. note:: The content of this page is generated by running `trb_hebrew.py` located in the ``tests/`` directory. This needs to be done explicitly, independently of updating the documentation using Sphinx. Friendly-traceback version: 0.7.53 Python version: 3.10.6 ArithmeticError --------------- Generic ~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_arithmetic_error.py", line 9, in test_Generic raise ArithmeticError('error') ArithmeticError: error `ArithmeticError` is the base class for those built-in exceptions that are raised for various arithmetic errors. Exception raised on line `9` of file 'TESTS:\runtime\test_arithmetic_error.py'. 4| def test_Generic(): 5| try: 6| # I am not aware of any way in which this error is raised directly 7| # Usually, a subclass such as ZeroDivisionError, etc., would 8| # likely be raised. --> 9| raise ArithmeticError('error') 10| except ArithmeticError as e: ArithmeticError: AssertionError -------------- Generic ~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_assertion_error.py", line 8, in test_Generic raise AssertionError("Fake message") AssertionError: Fake message ב-Python, מילת המפתח `assert` משמשת בהצהרות של הטופס `assert condition`, כדי לאשר ש`תנאי` אינו `שקר`, ולא שווה ערך ל'שקר' כמו רשימה ריקה וכו'. אם 'תנאי' הוא 'שקר' או שווה ערך, מועלית 'AssertionError'. Exception raised on line `8` of file 'TESTS:\runtime\test_assertion_error.py'. 4| def test_Generic(): 5| try: 6| # We raise it explicitly, rather than with the keyword assert, since 7| # we don't want pytest to rewrite out test. -->8| raise AssertionError("Fake message") 9| except AssertionError as e: AssertionError: AttributeError -------------- Attribute from other module ~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_attribute_error.py", line 336, in test_Attribute_from_other_module keyword.pi AttributeError: module 'keyword' has no attribute 'pi' האם התכוונת לאחד המודולים הבאים: `math, cmath`? 'AttributeError' מתרחשת כאשר הקוד מכיל משהו כמו 'object.x' ו-'x' אינו שיטה או תכונה (משתנה) השייכת ל-'object'. במקום המודול `keyword`, אולי רצית להשתמש התכונה 'pi' של אחד מהמודולים הבאים: `math, cmath`. Exception raised on line `336` of file 'TESTS:\runtime\test_attribute_error.py'. 332| assert "Did you mean `math`?" in result 333| 334| import cmath 335| try: -->336| keyword.pi ^^^^^^^^^^ 337| except AttributeError as e: keyword: from PYTHON_LIB:\keyword.py Builtin function ~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_attribute_error.py", line 229, in test_Builtin_function len.text AttributeError: 'builtin_function_or_method' object has no attribute 'text' האם התכוונת ל "len (text)"? 'AttributeError' מתרחשת כאשר הקוד מכיל משהו כמו 'object.x' ו-'x' אינו שיטה או תכונה (משתנה) השייכת ל-'object'. `len` היא פונקציה. אולי התכוונת לכתוב `len (text)` Exception raised on line `229` of file 'TESTS:\runtime\test_attribute_error.py'. 226| def test_Builtin_function(): 227| text = 'Hello world!' 228| try: -->229| len.text ^^^^^^^^ 230| except AttributeError as e: text: 'Hello world!' len: Builtin module with no file ~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_attribute_error.py", line 247, in test_Builtin_module_with_no_file sys.foo AttributeError: module 'sys' has no attribute 'foo' 'AttributeError' מתרחשת כאשר הקוד מכיל משהו כמו 'object.x' ו-'x' אינו שיטה או תכונה (משתנה) השייכת ל-'object'. פייתון אומר לנו שאין אובייקט בשם "foo" שנמצא במודול `sys`. Exception raised on line `247` of file 'TESTS:\runtime\test_attribute_error.py'. 243| """Issue 116""" 244| import sys 245| 246| try: -->247| sys.foo ^^^^^^^ 248| except AttributeError as e: sys: Circular import ~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_attribute_error.py", line 368, in test_Circular_import import my_turtle1 File "TESTS:\my_turtle1.py", line 4, in a = my_turtle1.something AttributeError: partially initialized module 'my_turtle1' has no attribute 'something' (most likely due to a circular import) האם נתת לתוכנית שלך את אותו שם כמו מודול פייתון? 'AttributeError' מתרחשת כאשר הקוד מכיל משהו כמו 'object.x' ו-'x' אינו שיטה או תכונה (משתנה) השייכת ל-'object'. אני חושד שהשתמשת בשם 'my_turtle1 .py' עבור התוכנית שלך ושאתה גם רוצה לייבא מודול עם אותו שם מהספרייה הסטנדרטית של פייתון. אם כן, עליך להשתמש בשם אחר לתוכנית שלך. Execution stopped on line `368` of file 'TESTS:\runtime\test_attribute_error.py'. 365| from friendly_traceback.runtime_errors import stdlib_modules 366| stdlib_modules.names.add("my_turtle1") 367| try: -->368| import my_turtle1 369| except AttributeError as e: Exception raised on line `4` of file 'TESTS:\my_turtle1.py'. 1| """To test attribute error of partially initialized module.""" 2| import my_turtle1 3| -->4| a = my_turtle1.something ^^^^^^^^^^^^^^^^^^^^ my_turtle1: from TESTS:\my_turtle1.py Circular import b ~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_attribute_error.py", line 386, in test_Circular_import_b import circular_c File "TESTS:\circular_c.py", line 4, in a = circular_c.something AttributeError: partially initialized module 'circular_c' has no attribute 'something' (most likely due to a circular import) יש לך יבוא מעגלי. 'AttributeError' מתרחשת כאשר הקוד מכיל משהו כמו 'object.x' ו-'x' אינו שיטה או תכונה (משתנה) השייכת ל-'object'. פייתון ציין כי המודול `{module}` לא יובא במלואו. זה יכול לקרות אם במהלך ביצוע הקוד במודול 'circular_c' נעשה ניסיון לייבא את אותו מודול שוב. Execution stopped on line `386` of file 'TESTS:\runtime\test_attribute_error.py'. 384| def test_Circular_import_b(): 385| try: -->386| import circular_c 387| except AttributeError as e: Exception raised on line `4` of file 'TESTS:\circular_c.py'. 1| # Attribute error for partially initialize module 2| import circular_c 3| -->4| a = circular_c.something ^^^^^^^^^^^^^^^^^^^^ circular_c: from TESTS:\circular_c.py Generic ~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_attribute_error.py", line 26, in test_Generic A.x # testing type AttributeError: type object 'A' has no attribute 'x' 'AttributeError' מתרחשת כאשר הקוד מכיל משהו כמו 'object.x' ו-'x' אינו שיטה או תכונה (משתנה) השייכת ל-'object'. לאובייקט 'A' אין תכונה בשם 'x'. Exception raised on line `26` of file 'TESTS:\runtime\test_attribute_error.py'. 22| class A: 23| pass 24| 25| try: -->26| A.x # testing type ^^^ 27| except AttributeError as e: A: defined in Generic different frame ~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_attribute_error.py", line 50, in test_Generic_different_frame a.attr AttributeError: 'A' object has no attribute 'attr'. Did you mean: 'attr2'? האם התכוונת ל 'attr2'? 'AttributeError' מתרחשת כאשר הקוד מכיל משהו כמו 'object.x' ו-'x' אינו שיטה או תכונה (משתנה) השייכת ל-'object'. לאובייקט 'a' אין תכונה בשם 'attr'. אולי התכוונת לכתוב 'a. attr2' במקום 'a. attr' Exception raised on line `50` of file 'TESTS:\runtime\test_attribute_error.py'. 46| return A() 47| 48| a = f() 49| try: -->50| a.attr ^^^^^^ 51| except AttributeError as e: a: defined in .f> Generic instance ~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_attribute_error.py", line 69, in test_Generic_instance a.x AttributeError: 'A' object has no attribute 'x' 'AttributeError' מתרחשת כאשר הקוד מכיל משהו כמו 'object.x' ו-'x' אינו שיטה או תכונה (משתנה) השייכת ל-'object'. לאובייקט 'a' אין תכונה בשם 'x'. Exception raised on line `69` of file 'TESTS:\runtime\test_attribute_error.py'. 66| pass 67| a = A() 68| try: -->69| a.x ^^^ 70| except AttributeError as e: a: defined in Module attribute typo ~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_attribute_error.py", line 150, in test_Module_attribute_typo math.cost AttributeError: module 'math' has no attribute 'cost'. Did you mean: 'cos'? האם התכוונת ל 'cos'? 'AttributeError' מתרחשת כאשר הקוד מכיל משהו כמו 'object.x' ו-'x' אינו שיטה או תכונה (משתנה) השייכת ל-'object'. Instead of writing `math.cost`, perhaps you meant to write one of the following names which are attributes of module `math`: `cos, cosh` Exception raised on line `150` of file 'TESTS:\runtime\test_attribute_error.py'. 145| assert "Did you mean `ascii_lowercase`" in result 146| 147| import math 148| 149| try: -->150| math.cost ^^^^^^^^^ 151| except AttributeError as e: math: Nonetype ~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_attribute_error.py", line 191, in test_Nonetype a.b AttributeError: 'NoneType' object has no attribute 'b' 'AttributeError' מתרחשת כאשר הקוד מכיל משהו כמו 'object.x' ו-'x' אינו שיטה או תכונה (משתנה) השייכת ל-'object'. אתה מנסה לגשת למאפיין 'b' עבור משתנה שערכו 'כלום'(none). Exception raised on line `191` of file 'TESTS:\runtime\test_attribute_error.py'. 188| def test_Nonetype(): 189| a = None 190| try: -->191| a.b ^^^ 192| except AttributeError as e: a: None Object attribute typo ~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_attribute_error.py", line 86, in test_Object_attribute_typo a.appendh(4) AttributeError: 'list' object has no attribute 'appendh'. Did you mean: 'append'? האם התכוונת ל 'append'? 'AttributeError' מתרחשת כאשר הקוד מכיל משהו כמו 'object.x' ו-'x' אינו שיטה או תכונה (משתנה) השייכת ל-'object'. לאובייקט 'a' אין תכונה בשם 'appendh'. אולי התכוונת לכתוב 'a. append' במקום 'a. appendh' Exception raised on line `86` of file 'TESTS:\runtime\test_attribute_error.py'. 82| def test_Object_attribute_typo(): 83| # 84| try: 85| a = [1, 2, 3] -->86| a.appendh(4) ^^^^^^^^^ 87| except AttributeError as e: a: [1, 2, 3] Perhaps comma ~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_attribute_error.py", line 213, in test_Perhaps_comma .defg] AttributeError: 'str' object has no attribute 'defg' האם התכוונת להפריד שמות אובייקטים בפסיק? 'AttributeError' מתרחשת כאשר הקוד מכיל משהו כמו 'object.x' ו-'x' אינו שיטה או תכונה (משתנה) השייכת ל-'object'. 'defg' אינה תכונה של 'abcd'. עם זאת, הן "abcd" ו- "defg" הם אובייקטים ידועים. אולי כתבת תקופה להפריד בין שני האובייקטים האלה, במקום להשתמש בפסיק. Exception raised on line `213` of file 'TESTS:\runtime\test_attribute_error.py'. 208| defg = "world" 209| 210| # fmt: off 211| try: 212| a = [abcd ^^^^ -->213| .defg] ^^^^^ 214| # fmt: on abcd: 'hello' defg: 'world' Read only ~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_attribute_error.py", line 289, in test_Read_only f.b = 1 AttributeError: 'F' object attribute 'b' is read-only 'AttributeError' מתרחשת כאשר הקוד מכיל משהו כמו 'object.x' ו-'x' אינו שיטה או תכונה (משתנה) השייכת ל-'object'. Object `f` uses `__slots__` to specify which attributes can be changed. The value of attribute `f.b` cannot be changed. The only attribute of `f` whose value can be changed is`a`. Exception raised on line `289` of file 'TESTS:\runtime\test_attribute_error.py'. 285| b = 2 286| 287| f = F() 288| try: -->289| f.b = 1 ^^^ 290| except AttributeError as e: f: defined in f.b: 2 Shadow stdlib module ~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_attribute_error.py", line 172, in test_Shadow_stdlib_module turtle.Pen AttributeError: module 'turtle' has no attribute 'Pen' האם נתת לתוכנית שלך את אותו שם כמו מודול פייתון? 'AttributeError' מתרחשת כאשר הקוד מכיל משהו כמו 'object.x' ו-'x' אינו שיטה או תכונה (משתנה) השייכת ל-'object'. You imported a module named `turtle` from `TESTS:\turtle.py`. There is also a module named `turtle` in Python's standard library. Perhaps you need to rename your module. Exception raised on line `172` of file 'TESTS:\runtime\test_attribute_error.py'. 168| def test_Shadow_stdlib_module(): 169| import turtle 170| 171| try: -->172| turtle.Pen ^^^^^^^^^^ 173| except AttributeError as e: turtle: from TESTS:\turtle.py Tuple by accident ~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_attribute_error.py", line 305, in test_Tuple_by_accident something.upper() AttributeError: 'tuple' object has no attribute 'upper' כתבת פסיק בטעות? 'AttributeError' מתרחשת כאשר הקוד מכיל משהו כמו 'object.x' ו-'x' אינו שיטה או תכונה (משתנה) השייכת ל-'object'. `something` הוא צמד (tuple ) המכיל פריט בודד אשר אכן מכיל "'upper' 'כתכונה. אולי הוספת פסיק נגרר בטעות בסוף השורה שם הגדרת את "something". Exception raised on line `305` of file 'TESTS:\runtime\test_attribute_error.py'. 302| def test_Tuple_by_accident(): 303| something = "abc", # note trailing comma 304| try: -->305| something.upper() ^^^^^^^^^^^^^^^ 306| except AttributeError as e: something: ('abc',) Use builtin ~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_attribute_error.py", line 103, in test_Use_builtin a.length() AttributeError: 'list' object has no attribute 'length' האם התכוונת ל 'len(a)'? 'AttributeError' מתרחשת כאשר הקוד מכיל משהו כמו 'object.x' ו-'x' אינו שיטה או תכונה (משתנה) השייכת ל-'object'. לאובייקט 'a' אין תכונה בשם 'length'. אולי תוכל להשתמש בפונקציה הסטנדרטית של Python `len` במקום: `len(a)`. Exception raised on line `103` of file 'TESTS:\runtime\test_attribute_error.py'. 99| def test_Use_builtin(): 100| # 101| try: 102| a = [1, 2, 3] -->103| a.length() ^^^^^^^^ 104| except AttributeError as e: a: [1, 2, 3] Use join with str ~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_attribute_error.py", line 351, in test_Use_join_with_str a = ['a', '2'].join('abc') + ['b', '3'].join('\n') AttributeError: 'list' object has no attribute 'join' האם התכוונת ל ''abc'.join(['a', '2']) `? 'AttributeError' מתרחשת כאשר הקוד מכיל משהו כמו 'object.x' ו-'x' אינו שיטה או תכונה (משתנה) השייכת ל-'object'. לאובייקט '['a', '2']' אין תכונה בשם 'join'. אולי רצית משהו כמו ''abc'.join(['a', '2'])'. Exception raised on line `351` of file 'TESTS:\runtime\test_attribute_error.py'. 349| def test_Use_join_with_str(): 350| try: -->351| a = ['a', '2'].join('abc') + ['b', '3'].join('\n') ^^^^^^^^^^^^^^^ 352| except AttributeError as e: Use synonym ~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_attribute_error.py", line 120, in test_Use_synonym a.add(4) AttributeError: 'list' object has no attribute 'add' האם התכוונת ל 'append'? 'AttributeError' מתרחשת כאשר הקוד מכיל משהו כמו 'object.x' ו-'x' אינו שיטה או תכונה (משתנה) השייכת ל-'object'. לאובייקט 'a' אין תכונה בשם 'add'. עם זאת, ל- 'a' יש את התכונות הבאות בעלות משמעויות דומות: `append, extend, insert`. Exception raised on line `120` of file 'TESTS:\runtime\test_attribute_error.py'. 116| def test_Use_synonym(): 117| # 118| try: 119| a = [1, 2, 3] -->120| a.add(4) ^^^^^ 121| except AttributeError as e: a: [1, 2, 3] Using slots ~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_attribute_error.py", line 268, in test_Using_slots f.b = 1 AttributeError: 'F' object has no attribute 'b' 'AttributeError' מתרחשת כאשר הקוד מכיל משהו כמו 'object.x' ו-'x' אינו שיטה או תכונה (משתנה) השייכת ל-'object'. לאובייקט 'f' אין תכונה בשם 'b'. שים לב שהאובייקט `f` משתמש ב- `__slots__` אשר מונע יצירת תכונות חדשות. להלן כמה מהתכונות הידועות: `a`. Exception raised on line `268` of file 'TESTS:\runtime\test_attribute_error.py'. 264| __slots__ = ["a"] 265| 266| f = F() 267| try: -->268| f.b = 1 ^^^ 269| except AttributeError as e: f: defined in FileNotFoundError ----------------- Directory not found ~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_file_not_found_error.py", line 73, in test_Directory_not_found open("does_not_exist/file.txt") FileNotFoundError: [Errno 2] No such file or directory: 'does_not_exist/file.txt' חריג של 'FileNotFoundError' מציין שמנסים לפתוח קובץ שפייתון לא מצא. זה יכול להיות בגלל שגיאת כתיב בשם הקובץ. בתוכנית שלך, שם ה- הקובץ שלא ניתן למצוא הוא 'file.txt'. does_not_exist is not a valid directory. Exception raised on line `73` of file 'TESTS:\runtime\test_file_not_found_error.py'. 71| def test_Directory_not_found(): 72| try: -->73| open("does_not_exist/file.txt") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 74| except FileNotFoundError as e: open: Filename not found ~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_file_not_found_error.py", line 7, in test_Filename_not_found open("does_not_exist") FileNotFoundError: [Errno 2] No such file or directory: 'does_not_exist' חריג של 'FileNotFoundError' מציין שמנסים לפתוח קובץ שפייתון לא מצא. זה יכול להיות בגלל שגיאת כתיב בשם הקובץ. בתוכנית שלך, שם ה- הקובץ שלא ניתן למצוא הוא 'does_not_exist'. It was expected to be found in the `C:\Users\Andre\github\friendly-traceback\tests` directory. אין לי מידע נוסף עבורך. Exception raised on line `7` of file 'TESTS:\runtime\test_file_not_found_error.py'. 5| def test_Filename_not_found(): 6| try: -->7| open("does_not_exist") ^^^^^^^^^^^^^^^^^^^^^^ 8| except FileNotFoundError as e: open: Filename not found 2 ~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_file_not_found_error.py", line 31, in test_Filename_not_found_2 open("setupp.py") FileNotFoundError: [Errno 2] No such file or directory: 'setupp.py' האם התכוונת ל`setup.py`? חריג של 'FileNotFoundError' מציין שמנסים לפתוח קובץ שפייתון לא מצא. זה יכול להיות בגלל שגיאת כתיב בשם הקובץ. בתוכנית שלך, שם ה- הקובץ שלא ניתן למצוא הוא 'setupp.py'. It was expected to be found in the `C:\Users\Andre\github\friendly-traceback` directory. לקובץ `setup.py` יש שם דומה. Exception raised on line `31` of file 'TESTS:\runtime\test_file_not_found_error.py'. 27| if chdir: 28| os.chdir("..") 29| 30| try: -->31| open("setupp.py") ^^^^^^^^^^^^^^^^^ 32| except FileNotFoundError as e: open: Filename not found 3 ~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_file_not_found_error.py", line 54, in test_Filename_not_found_3 open("setup.pyg") FileNotFoundError: [Errno 2] No such file or directory: 'setup.pyg' האם התכוונת ל`setup.py`? חריג של 'FileNotFoundError' מציין שמנסים לפתוח קובץ שפייתון לא מצא. זה יכול להיות בגלל שגיאת כתיב בשם הקובץ. בתוכנית שלך, שם ה- הקובץ שלא ניתן למצוא הוא 'setup.pyg'. It was expected to be found in the `C:\Users\Andre\github\friendly-traceback` directory. אולי התכוונת לאחד מהקבצים הבאים עם שמות דומים: `setup.py`, `setup.cfg` Exception raised on line `54` of file 'TESTS:\runtime\test_file_not_found_error.py'. 51| if chdir: 52| os.chdir("..") 53| try: -->54| open("setup.pyg") ^^^^^^^^^^^^^^^^^ 55| except FileNotFoundError as e: open: ImportError ----------- Simple import error ~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_import_error.py", line 56, in test_Simple_import_error from math import Pi ImportError: cannot import name 'Pi' from 'math' (unknown location) האם התכוונת ל 'pi'? חריג של 'ImportError' מציין כי אובייקט מסוים לא יכול היה להיות מיובא ממודול או מחבילה. לרוב, זה קורה כי שם האובייקט לא מאוית נכון. אולי התכוונת לייבא 'pi' (מתוך 'math') במקום 'Pi' Exception raised on line `56` of file 'TESTS:\runtime\test_import_error.py'. 52| multiple_import_on_same_line() 53| wrong_case() 54| 55| try: -->56| from math import Pi 57| except ImportError as e: IndexError ---------- Assignment ~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_index_error.py", line 87, in test_Assignment a[13] = 1 IndexError: list assignment index out of range 'IndexError' מתרחש כשאתה מנסה להשיג פריט מרשימה, צמד או אובייקט דומה (רצף), ומשתמש באינדקס אשר לא קיים; בדרך כלל, זה קורה מכיוון שהאינדקס שאתה נותן גדול מאורך הרצף. You have tried to assign a value to index `13` of `a`, רשימה (`list`) of length `10`. ערכי האינדקס התקפים של 'a' הם מספרים שלמים הנעים בין `-10` עד `9`. Exception raised on line `87` of file 'TESTS:\runtime\test_index_error.py'. 83| assert "You have tried to assign a value to index `1` of `b`," in result 84| assert "a `list` which contains no item." in result 85| 86| try: -->87| a[13] = 1 ^^^^^ 88| except IndexError as e: a: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] Empty ~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_index_error.py", line 42, in test_Empty c = a[1] IndexError: list index out of range `a` אינו מכיל פריט. 'IndexError' מתרחש כשאתה מנסה להשיג פריט מרשימה, צמד או אובייקט דומה (רצף), ומשתמש באינדקס אשר לא קיים; בדרך כלל, זה קורה מכיוון שהאינדקס שאתה נותן גדול מאורך הרצף. ניסית לקבל את הפריט עם האינדקס '1' של 'a', רשימה (`list`) שאינו מכיל פריט. Exception raised on line `42` of file 'TESTS:\runtime\test_index_error.py'. 39| def test_Empty(): 40| a = [] 41| try: -->42| c = a[1] ^^^^ 43| except IndexError as e: a: [] Long list ~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_index_error.py", line 27, in test_Long_list print(a[60], b[0]) IndexError: list index out of range 'IndexError' מתרחש כשאתה מנסה להשיג פריט מרשימה, צמד או אובייקט דומה (רצף), ומשתמש באינדקס אשר לא קיים; בדרך כלל, זה קורה מכיוון שהאינדקס שאתה נותן גדול מאורך הרצף. ניסית לקבל את הפריט עם האינדקס '60' של 'a', רשימה (`list`) של אורך `40`. ערכי האינדקס התקפים של 'a' הם מספרים שלמים הנעים בין `-40` עד `39`. Exception raised on line `27` of file 'TESTS:\runtime\test_index_error.py'. 24| a = list(range(40)) 25| b = tuple(range(50)) 26| try: -->27| print(a[60], b[0]) ^^^^^ 28| except IndexError as e: a: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, ...] len(a): 40 Short tuple ~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_index_error.py", line 10, in test_Short_tuple print(a[3], b[2]) IndexError: tuple index out of range זכור: הפריט הראשון של צמד ('tuple') אינו באינדקס 1 אלא באינדקס 0. 'IndexError' מתרחש כשאתה מנסה להשיג פריט מרשימה, צמד או אובייקט דומה (רצף), ומשתמש באינדקס אשר לא קיים; בדרך כלל, זה קורה מכיוון שהאינדקס שאתה נותן גדול מאורך הרצף. ניסית לקבל את הפריט עם האינדקס '3' של 'a', צמד ('tuple') של אורך `3`. ערכי האינדקס התקפים של 'a' הם מספרים שלמים הנעים בין `-3` עד `2`. Exception raised on line `10` of file 'TESTS:\runtime\test_index_error.py'. 7| a = (1, 2, 3) 8| b = [1, 2, 3] 9| try: -->10| print(a[3], b[2]) ^^^^ 11| except IndexError as e: a: (1, 2, 3) KeyError -------- ChainMap ~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "PYTHON_LIB:\collections\__init__.py", line 1056, in pop return self.maps[0].pop(key, *args) KeyError: 42 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "TESTS:\runtime\test_key_error.py", line 65, in test_ChainMap d.pop(42) KeyError: 'Key not found in the first mapping: 42' 'KeyError' נזרק כאשר ערך אינו נמצא כ- מפתח במילון או באובייקט דומה. לא ניתן למצוא את המפתח '42' ב- 'd', אובייקט מסוג 'ChainMap'. Exception raised on line `65` of file 'TESTS:\runtime\test_key_error.py'. 62| from collections import ChainMap 63| d = ChainMap({}, {}) 64| try: -->65| d.pop(42) ^^^^^^^^^ 66| except KeyError as e: d: ChainMap({}, {}) d.pop: of ChainMap({}, {}) Forgot to convert to string ~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_key_error.py", line 120, in test_Forgot_to_convert_to_string print(squares[2]) KeyError: 2 שכחת להמיר את '2' למחרוזת? 'KeyError' נזרק כאשר ערך אינו נמצא כ- מפתח במילון או באובייקט דומה. לא ניתן למצוא את המפתח `2` במילון (dict) בשם `squares`. `squares` מכיל מפתח מחרוזת שזהה ל- `str(2)`. אולי שכחת להמיר את המפתח למחרוזת. Exception raised on line `120` of file 'TESTS:\runtime\test_key_error.py'. 117| def test_Forgot_to_convert_to_string(): 118| squares = {"1": 1, "2": 4, "3": 9} 119| try: -->120| print(squares[2]) ^^^^^^^^^^ 121| except KeyError as e: squares: {'1': 1, '2': 4, '3': 9} Generic key error ~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_key_error.py", line 46, in test_Generic_key_error d["c"] KeyError: 'c' 'KeyError' נזרק כאשר ערך אינו נמצא כ- מפתח במילון או באובייקט דומה. לא ניתן למצוא את המפתח `'c'` במילון (dict) בשם `d`. Exception raised on line `46` of file 'TESTS:\runtime\test_key_error.py'. 43| def test_Generic_key_error(): 44| d = {"a": 1, "b": 2} 45| try: -->46| d["c"] ^^^^^^ 47| except KeyError as e: d: {'a': 1, 'b': 2} Popitem empty ChainMap ~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "PYTHON_LIB:\collections\__init__.py", line 1049, in popitem return self.maps[0].popitem() KeyError: 'popitem(): dictionary is empty' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "TESTS:\runtime\test_key_error.py", line 27, in test_Popitem_empty_ChainMap alpha.popitem() KeyError: 'No keys found in the first mapping.' `alpha` הוא `ChainMap` ריק. 'KeyError' נזרק כאשר ערך אינו נמצא כ- מפתח במילון או באובייקט דומה. ניסית לקבל פריט מתוך 'alpha' שהוא 'ChainMap' ריק. Exception raised on line `27` of file 'TESTS:\runtime\test_key_error.py'. 24| from collections import ChainMap 25| alpha = ChainMap({}, {}) 26| try: -->27| alpha.popitem() ^^^^^^^^^^^^^^^ 28| except KeyError as e: alpha: ChainMap({}, {}) alpha.popitem: of ChainMap({}, {}) Popitem empty dict ~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_key_error.py", line 8, in test_Popitem_empty_dict d.popitem() KeyError: 'popitem(): dictionary is empty' 'd' הוא מילון ('dict') ריק. 'KeyError' נזרק כאשר ערך אינו נמצא כ- מפתח במילון או באובייקט דומה. ניסית לקבל פריט מתוך 'd' שהוא מילון ('dict') ריק. Exception raised on line `8` of file 'TESTS:\runtime\test_key_error.py'. 5| def test_Popitem_empty_dict(): 6| d = {} 7| try: -->8| d.popitem() ^^^^^^^^^^^ 9| except KeyError as e: d: {} d.popitem: Similar names ~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_key_error.py", line 151, in test_Similar_names a = second["alpha"] KeyError: 'alpha' האם התכוונת ל ''alpha0''? 'KeyError' נזרק כאשר ערך אינו נמצא כ- מפתח במילון או באובייקט דומה. לא ניתן למצוא את המפתח `'alpha'` במילון (dict) בשם `second`. 'second' מכיל כמה מפתחות הדומים ל- ''alpha'' כולל: `'alpha0', 'alpha11', 'alpha12'`. Exception raised on line `151` of file 'TESTS:\runtime\test_key_error.py'. 147| assert ok, diff 148| 149| second = {"alpha0": 1, "alpha11": 2, "alpha12": 3} 150| try: -->151| a = second["alpha"] ^^^^^^^^^^^^^^^ 152| except KeyError as e: second: {'alpha0': 1, 'alpha11': 2, 'alpha12': 3} String by mistake ~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_key_error.py", line 102, in test_String_by_mistake d["(0, 0)"] KeyError: '(0, 0)' האם המרת את '(0, 0)' למחרוזת בטעות? 'KeyError' נזרק כאשר ערך אינו נמצא כ- מפתח במילון או באובייקט דומה. לא ניתן למצוא את המפתח `'(0, 0)'` במילון (dict) בשם `d`. `'(0, 0)'` היא מחרוזת. יש מפתח של 'd' שייצוג המחרוזות שלו זהה ל- ''(0, 0)''. Exception raised on line `102` of file 'TESTS:\runtime\test_key_error.py'. 98| chain_map_string_by_mistake() # do not show in docs 99| 100| d = {(0, 0): "origin"} 101| try: -->102| d["(0, 0)"] ^^^^^^^^^^^ 103| except KeyError as e: d: {(0, 0): 'origin'} LookupError ----------- Generic ~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_lookup_error.py", line 10, in test_Generic raise LookupError("Fake message") LookupError: Fake message 'LookupError' היא מחלקת הבסיס לחריגים שמועלים כאשר המפתח או אינדקס שמשתמשים בהם על מפה או רצף (רשימה,צמד וכדומה) אינם תקפים. ניתן גם להעלות אותו ישירות על ידי codecs.lookup (). Exception raised on line `10` of file 'TESTS:\runtime\test_lookup_error.py'. 4| def test_Generic(): 5| try: 6| # LookupError is the base class for KeyError and IndexError. 7| # It should normally not be raised by user code, 8| # other than possibly codecs.lookup(), which is why we raise 9| # it directly here for our example. -->10| raise LookupError("Fake message") 11| except LookupError as e: LookupError: ModuleNotFoundError ------------------- Need to install module ~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_module_not_found_error.py", line 80, in test_Need_to_install_module import alphabet ModuleNotFoundError: No module named 'alphabet' חריג `ModuleNotFoundError` נזרק כאשר מנסים לייבא מודול שפייתון לא מצא . זה יכול להיות בגלל שגיאת כתיב בשם המודול או מכיוון שהוא לא מותקן במחשב שלך. לא ניתן לייבא מודול בשם 'alphabet'. אולי אתה צריך להתקין אותו. Exception raised on line `80` of file 'TESTS:\runtime\test_module_not_found_error.py'. 78| def test_Need_to_install_module(): 79| try: -->80| import alphabet 81| except ModuleNotFoundError as e: Not a package ~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_module_not_found_error.py", line 23, in test_Not_a_package import os.xxx ModuleNotFoundError: No module named 'os.xxx'; 'os' is not a package חריג `ModuleNotFoundError` נזרק כאשר מנסים לייבא מודול שפייתון לא מצא . זה יכול להיות בגלל שגיאת כתיב בשם המודול או מכיוון שהוא לא מותקן במחשב שלך. לא ניתן לייבא את 'xxx' מתוך 'os'. Exception raised on line `23` of file 'TESTS:\runtime\test_module_not_found_error.py'. 20| def test_Not_a_package(): 21| 22| try: -->23| import os.xxx 24| except ModuleNotFoundError as e: Not a package similar name ~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_module_not_found_error.py", line 37, in test_Not_a_package_similar_name import os.pathh ModuleNotFoundError: No module named 'os.pathh'; 'os' is not a package האם התכוונת ל-`import os.path`? ('יבא os.path)' ? חריג `ModuleNotFoundError` נזרק כאשר מנסים לייבא מודול שפייתון לא מצא . זה יכול להיות בגלל שגיאת כתיב בשם המודול או מכיוון שהוא לא מותקן במחשב שלך. אולי התכוונת ל'ייבא os. path '. 'path' הוא שם הדומה ל- 'pathh' והוא מודול ש ניתן לייבא מ 'os'. Exception raised on line `37` of file 'TESTS:\runtime\test_module_not_found_error.py'. 35| def test_Not_a_package_similar_name(): 36| try: -->37| import os.pathh 38| except ModuleNotFoundError as e: Object not module ~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_module_not_found_error.py", line 51, in test_Object_not_module import os.open ModuleNotFoundError: No module named 'os.open'; 'os' is not a package האם התכוונת ל-`from os import open`? ('מתוך os יבא open)' ? חריג `ModuleNotFoundError` נזרק כאשר מנסים לייבא מודול שפייתון לא מצא . זה יכול להיות בגלל שגיאת כתיב בשם המודול או מכיוון שהוא לא מותקן במחשב שלך. 'open' אינו מודול נפרד אלא אובייקט שהוא חלק מ- 'os'. Exception raised on line `51` of file 'TESTS:\runtime\test_module_not_found_error.py'. 49| def test_Object_not_module(): 50| try: -->51| import os.open 52| except ModuleNotFoundError as e: open: Similar object not module ~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_module_not_found_error.py", line 65, in test_Similar_object_not_module import os.opend ModuleNotFoundError: No module named 'os.opend'; 'os' is not a package האם התכוונת ל-`from os import open`? ('מתוך os יבוא open)' ? חריג `ModuleNotFoundError` נזרק כאשר מנסים לייבא מודול שפייתון לא מצא . זה יכול להיות בגלל שגיאת כתיב בשם המודול או מכיוון שהוא לא מותקן במחשב שלך. אולי התכוונת ל `from os import open` (מ- os יבא topen'. ') `open` הוא שם הדומה ל- `opend` והוא אובייקט ש ניתן לייבא מ 'os'. אובייקטים אחרים עם שמות דומים שהם חלק מ "os" כלול "popen". Exception raised on line `65` of file 'TESTS:\runtime\test_module_not_found_error.py'. 63| def test_Similar_object_not_module(): 64| try: -->65| import os.opend 66| except ModuleNotFoundError as e: Standard library module ~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_module_not_found_error.py", line 7, in test_Standard_library_module import Tkinter ModuleNotFoundError: No module named 'Tkinter' האם התכוונת ל 'tkinter'? חריג `ModuleNotFoundError` נזרק כאשר מנסים לייבא מודול שפייתון לא מצא . זה יכול להיות בגלל שגיאת כתיב בשם המודול או מכיוון שהוא לא מותקן במחשב שלך. לא ניתן לייבא מודול בשם 'Tkinter'. אולי אתה צריך להתקין אותו. במודולים הקיימים הבאים יש שמות דומים למודול שניסית לייבא: `tkinter, _tkinter` Exception raised on line `7` of file 'TESTS:\runtime\test_module_not_found_error.py'. 5| def test_Standard_library_module(): 6| try: -->7| import Tkinter 8| except ModuleNotFoundError as e: no curses ~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_module_not_found_error.py", line 97, in test_no_curses import curses ModuleNotFoundError: No module named '_curses' המודול "curses" מותקן לעתים רחוקות עם Python ב- Windows. חריג `ModuleNotFoundError` נזרק כאשר מנסים לייבא מודול שפייתון לא מצא . זה יכול להיות בגלל שגיאת כתיב בשם המודול או מכיוון שהוא לא מותקן במחשב שלך. ניסית לייבא את המודול "curses ". המודול "curses" מותקן לעתים רחוקות עם Python ב- Windows. Exception raised on line `97` of file 'TESTS:\runtime\test_module_not_found_error.py'. 95| def test_no_curses(): 96| try: -->97| import curses 98| except ModuleNotFoundError as e: NameError --------- Annotated variable ~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_name_error.py", line 31, in test_Annotated_variable y = x NameError: name 'x' is not defined האם השתמשת בנקודותיים במקום בסימן שוויון? חריג של 'NameError' מציין כי משתנה או הפונקציה אינו ידוע לפייתון. לרוב, הסיבה לכך היא שיש טעות כתיב. עם זאת, לפעמים זה בגלל שהשם משמש לפני שמגדירים אותו או נותנים לו ערך. בתוכנית שלך אין אובייקט בשם "x". רמז סוג נמצא עבור 'x' בהיקף global. אולי השתמשת בנקודותיים במקום בסימן שווה וכתבת x: 3 במקום x = 3 Exception raised on line `31` of file 'TESTS:\runtime\test_name_error.py'. 29| def test_Annotated_variable(): 30| try: -->31| y = x ^ 32| except NameError as e: Custom name ~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_name_error.py", line 234, in test_Custom_name python NameError: name 'python' is not defined אתה כבר משתמש בפייתון! חריג של 'NameError' מציין כי משתנה או הפונקציה אינו ידוע לפייתון. לרוב, הסיבה לכך היא שיש טעות כתיב. עם זאת, לפעמים זה בגלל שהשם משמש לפני שמגדירים אותו או נותנים לו ערך. אתה כבר משתמש בפייתון! Exception raised on line `234` of file 'TESTS:\runtime\test_name_error.py'. 232| def test_Custom_name(): 233| try: -->234| python ^^^^^^ 235| except NameError as e: Free variable referenced ~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_name_error.py", line 217, in test_Free_variable_referenced outer() File "TESTS:\runtime\test_name_error.py", line 213, in outer inner() File "TESTS:\runtime\test_name_error.py", line 212, in inner return var NameError: free variable 'var' referenced before assignment in enclosing scope. Did you mean: 'vars'? חריג של 'NameError' מציין כי משתנה או הפונקציה אינו ידוע לפייתון. לרוב, הסיבה לכך היא שיש טעות כתיב. עם זאת, לפעמים זה בגלל שהשם משמש לפני שמגדירים אותו או נותנים לו ערך. בתוכנית שלך, 'var' הוא שם לא ידוע שקיים בהיקף סגור, אך עדיין לא הוקצה לו ערך. Execution stopped on line `217` of file 'TESTS:\runtime\test_name_error.py'. 213| inner() 214| var = 4 215| 216| try: -->217| outer() ^^^^^^^ 218| except NameError as e: outer: defined in Exception raised on line `212` of file 'TESTS:\runtime\test_name_error.py'. 211| def inner(): -->212| return var ^^^ Generic ~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_name_error.py", line 15, in test_Generic this = something NameError: name 'something' is not defined חריג של 'NameError' מציין כי משתנה או הפונקציה אינו ידוע לפייתון. לרוב, הסיבה לכך היא שיש טעות כתיב. עם זאת, לפעמים זה בגלל שהשם משמש לפני שמגדירים אותו או נותנים לו ערך. בתוכנית שלך אין אובייקט בשם "something". אין לי מידע נוסף עבורך. Exception raised on line `15` of file 'TESTS:\runtime\test_name_error.py'. 13| def test_Generic(): 14| try: -->15| this = something ^^^^^^^^^ 16| except NameError as e: Missing import ~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_name_error.py", line 138, in test_Missing_import unicodedata.something NameError: name 'unicodedata' is not defined שכחת לייבא את 'unicodedata'? חריג של 'NameError' מציין כי משתנה או הפונקציה אינו ידוע לפייתון. לרוב, הסיבה לכך היא שיש טעות כתיב. עם זאת, לפעמים זה בגלל שהשם משמש לפני שמגדירים אותו או נותנים לו ערך. השם "unicodedata" לא מוגדר בתוכנית שלך. אולי שכחת לייבא את 'unicodedata' שנמצא בספרייה הסטנדרטית של פייתון. Exception raised on line `138` of file 'TESTS:\runtime\test_name_error.py'. 134| if friendly_traceback.get_lang() == "en": 135| assert "I have no additional information for you." in result 136| 137| try: -->138| unicodedata.something ^^^^^^^^^^^ 139| except NameError as e: Missing module name ~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_name_error.py", line 320, in test_Missing_module_name frame = Frame() NameError: name 'Frame' is not defined. Did you mean: 'frame'? שכחת להוסיף את `tkinter.`? חריג של 'NameError' מציין כי משתנה או הפונקציה אינו ידוע לפייתון. לרוב, הסיבה לכך היא שיש טעות כתיב. עם זאת, לפעמים זה בגלל שהשם משמש לפני שמגדירים אותו או נותנים לו ערך. בתוכנית שלך אין אובייקט בשם "Frame". The global object `tkinter` has an attribute named `Frame`. Perhaps you should have written `tkinter.Frame` instead of `Frame`. `Frame` is a name found in the following modules: tkinter, tracemalloc. Perhaps you forgot to import `Frame` from one of these modules. Exception raised on line `320` of file 'TESTS:\runtime\test_name_error.py'. 317| @pytest.mark.skipif(not tkinter, reason="tkinter not present; likely MacOS") 318| def test_Missing_module_name(): 319| try: -->320| frame = Frame() ^^^^^ 321| except NameError as e: Missing self 1 ~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_name_error.py", line 270, in test_Missing_self_1 str(a) File "TESTS:\runtime\test_name_error.py", line 261, in __str__ toys_list = add_toy( # ensure that it can see 'self' on following line NameError: name 'add_toy' is not defined Did you write `self` at the wrong place? חריג של 'NameError' מציין כי משתנה או הפונקציה אינו ידוע לפייתון. לרוב, הסיבה לכך היא שיש טעות כתיב. עם זאת, לפעמים זה בגלל שהשם משמש לפני שמגדירים אותו או נותנים לו ערך. בתוכנית שלך אין אובייקט בשם "add_toy". The local object ` defined in ` has an attribute named `add_toy`. Perhaps you should have written `self.add_toy(...` instead of `add_toy(self, ...`. Execution stopped on line `270` of file 'TESTS:\runtime\test_name_error.py'. 266| return "{} has no toys".format(self.name) 267| 268| a = Pet('Fido') 269| try: -->270| str(a) ^^^^^^ 271| except NameError as e: a: defined in str: Exception raised on line `261` of file 'TESTS:\runtime\test_name_error.py'. 259| def __str__(self): 260| # self at the wrong place -->261| toys_list = add_toy( # ensure that it can see 'self' on following line ^^^^^^^ 262| self, 'something') 263| if self.toys: Missing self 2 ~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_name_error.py", line 305, in test_Missing_self_2 str(a) File "TESTS:\runtime\test_name_error.py", line 297, in __str__ toys_list = add_toy('something') NameError: name 'add_toy' is not defined Did you forget to add `self.`? חריג של 'NameError' מציין כי משתנה או הפונקציה אינו ידוע לפייתון. לרוב, הסיבה לכך היא שיש טעות כתיב. עם זאת, לפעמים זה בגלל שהשם משמש לפני שמגדירים אותו או נותנים לו ערך. בתוכנית שלך אין אובייקט בשם "add_toy". A local object, ` defined in `, has an attribute named `add_toy`. Perhaps you should have written `self.add_toy` instead of `add_toy`. Execution stopped on line `305` of file 'TESTS:\runtime\test_name_error.py'. 301| return "{} has no toys".format(self.name) 302| 303| a = Pet('Fido') 304| try: -->305| str(a) ^^^^^^ 306| except NameError as e: a: defined in str: Exception raised on line `297` of file 'TESTS:\runtime\test_name_error.py'. 295| def __str__(self): 296| # Missing self. -->297| toys_list = add_toy('something') ^^^^^^^ 298| if self.toys: Synonym ~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_name_error.py", line 97, in test_Synonym cost # wrote from math import * above NameError: name 'cost' is not defined. Did you mean: 'cos'? האם התכוונת ל 'cos'? חריג של 'NameError' מציין כי משתנה או הפונקציה אינו ידוע לפייתון. לרוב, הסיבה לכך היא שיש טעות כתיב. עם זאת, לפעמים זה בגלל שהשם משמש לפני שמגדירים אותו או נותנים לו ערך. בתוכנית שלך אין אובייקט בשם "cost". במקום לכתוב 'cost', אולי התכוונת לאחד מהדברים הבאים: * היקף גלובלי `cos`, `cosh` Exception raised on line `97` of file 'TESTS:\runtime\test_name_error.py'. 93| if friendly_traceback.get_lang() == "en": 94| assert "The Python builtin `chr` has a similar name." in result 95| 96| try: -->97| cost # wrote from math import * above ^^^^ 98| except NameError as e: missing import2 ~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_name_error.py", line 153, in test_missing_import2 ABCMeta NameError: name 'ABCMeta' is not defined חריג של 'NameError' מציין כי משתנה או הפונקציה אינו ידוע לפייתון. לרוב, הסיבה לכך היא שיש טעות כתיב. עם זאת, לפעמים זה בגלל שהשם משמש לפני שמגדירים אותו או נותנים לו ערך. בתוכנית שלך אין אובייקט בשם "ABCMeta". `ABCMeta` is a name found in the following modules: selectors, typing, abc, numbers. Perhaps you forgot to import `ABCMeta` from one of these modules. Exception raised on line `153` of file 'TESTS:\runtime\test_name_error.py'. 151| def test_missing_import2(): 152| try: -->153| ABCMeta ^^^^^^^ 154| except NameError as e: missing import3 ~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_name_error.py", line 168, in test_missing_import3 AF_APPLETALK NameError: name 'AF_APPLETALK' is not defined חריג של 'NameError' מציין כי משתנה או הפונקציה אינו ידוע לפייתון. לרוב, הסיבה לכך היא שיש טעות כתיב. עם זאת, לפעמים זה בגלל שהשם משמש לפני שמגדירים אותו או נותנים לו ערך. בתוכנית שלך אין אובייקט בשם "AF_APPLETALK". `AF_APPLETALK` is a name found in module `socket`. Perhaps you forgot to write from socket import AF_APPLETALK Exception raised on line `168` of file 'TESTS:\runtime\test_name_error.py'. 166| def test_missing_import3(): 167| try: -->168| AF_APPLETALK ^^^^^^^^^^^^ 169| except NameError as e: missing import from other 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_name_error.py", line 183, in test_missing_import_from_other_1 plt.something NameError: name 'plt' is not defined Did you forget to import `matplotlib.pyplot`? חריג של 'NameError' מציין כי משתנה או הפונקציה אינו ידוע לפייתון. לרוב, הסיבה לכך היא שיש טעות כתיב. עם זאת, לפעמים זה בגלל שהשם משמש לפני שמגדירים אותו או נותנים לו ערך. The name `plt` is not defined in your program. Perhaps you forgot to write import matplotlib.pyplot as plt Exception raised on line `183` of file 'TESTS:\runtime\test_name_error.py'. 180| def test_missing_import_from_other_1(): 181| friendly_traceback.add_other_module_names_synonyms({"plt": "matplotlib.pyplot"}) 182| try: -->183| plt.something ^^^ 184| except NameError as e: missing import from other 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_name_error.py", line 197, in test_missing_import_from_other_2 show() NameError: name 'show' is not defined חריג של 'NameError' מציין כי משתנה או הפונקציה אינו ידוע לפייתון. לרוב, הסיבה לכך היא שיש טעות כתיב. עם זאת, לפעמים זה בגלל שהשם משמש לפני שמגדירים אותו או נותנים לו ערך. בתוכנית שלך אין אובייקט בשם "show". `show` is a name found in the following modules: mailcap, matplotlib.pyplot, funny. Perhaps you forgot to import `show` from one of these modules. Exception raised on line `197` of file 'TESTS:\runtime\test_name_error.py'. 194| def test_missing_import_from_other_2(): 195| friendly_traceback.add_other_attribute_names({"show": ["matplotlib.pyplot", "funny"] }) 196| try: -->197| show() ^^^^ 198| except NameError as e: special keyword ~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_name_error.py", line 352, in test_special_keyword brek NameError: name 'brek' is not defined האם התכוונת ל 'break'? חריג של 'NameError' מציין כי משתנה או הפונקציה אינו ידוע לפייתון. לרוב, הסיבה לכך היא שיש טעות כתיב. עם זאת, לפעמים זה בגלל שהשם משמש לפני שמגדירים אותו או נותנים לו ערך. I suspect you meant to write the keyword `break` and made a typo. Exception raised on line `352` of file 'TESTS:\runtime\test_name_error.py'. 349| if friendly_traceback.get_lang() == "en": 350| assert "Did you mean `continue`" in result 351| try: -->352| brek ^^^^ 353| except NameError as e: OsError ------- Urllib error ~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "PYTHON_LIB:\urllib\request.py", line 1348, in do_open ... שורות נוספות לא מוצגות. ... File "PYTHON_LIB:\socket.py", line 824, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): File "PYTHON_LIB:\socket.py", line 955, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno 11001] getaddrinfo failed During handling of the above exception, another exception occurred: Traceback (most recent call last): File "TESTS:\runtime\test_os_error.py", line 10, in test_Urllib_error request.urlopen("http://does_not_exist") URLError: שגיאה מסוג `URLError` היא תת-מחלקה של `OSError`. Nothing more specific is known about `URLError`. בדרך כלל מערכת ההפעלה מעלה חריג של 'OSError' כדי לציין שפעולה אסורה או כי משאב אינו זמין. אני חושד שאתה מנסה להתחבר לשרת ו שלא ניתן ליצור קשר. אם זה המצב, בדוק אם יש שגיאות כתיב בכתובת האתר ובדוק את חיבור האינטרנט שלך. Exception raised on line `10` of file 'TESTS:\runtime\test_os_error.py'. 6| @pytest.mark.skipif(random.randint(0, 50) < 59, reason="very long test") 7| def test_Urllib_error(): 8| from urllib import request, error 9| try: -->10| request.urlopen("http://does_not_exist") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 11| except error.URLError as e: request: from PYTHON_LIB:\urllib\request.py request.urlopen: invalid argument ~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_os_error.py", line 50, in test_invalid_argument open("c:\test.txt") OSError: [Errno 22] Invalid argument: 'c:\test.txt' אולי אתה צריך להכפיל את הלוֹכסן האחורי . בדרך כלל מערכת ההפעלה מעלה חריג של 'OSError' כדי לציין שפעולה אסורה או כי משאב אינו זמין. I suspect that you wrote a filename or path that contains at least one backslash character, `\`. Python likely interpreted this as indicating the beginning of what is known as an escape sequence. To solve the problem, either write a so-called 'raw string' by adding the letter `r` as a prefix in front of the filename or path, or replace all single backslash characters, `\`, by double ones: `\\`. Exception raised on line `50` of file 'TESTS:\runtime\test_os_error.py'. 47| if os.name != "nt": 48| return "Windows test only", "No result" 49| try: -->50| open("c:\test.txt") ^^^^^^^^^^^^^^^^^^^ 51| except OSError as e: open: no information ~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_os_error.py", line 30, in test_no_information raise OSError("Some unknown message") OSError: Some unknown message מקור השגיאה לא ידוע. בדרך כלל מערכת ההפעלה מעלה חריג של 'OSError' כדי לציין שפעולה אסורה או כי משאב אינו זמין. אין מידע על חריג זה. Please report this example to https://github.com/friendly-traceback/friendly-traceback/issues/new If you are using a REPL, use `www('bug')` to do so. אם אתה משתמש במסוף ידידותי, השתמש ב- 'www ()' כדי חפש באינטרנט את המקרה הספציפי הזה. Exception raised on line `30` of file 'TESTS:\runtime\test_os_error.py'. 27| old_debug = friendly_traceback.debug_helper.DEBUG 28| friendly_traceback.debug_helper.DEBUG = False 29| try: -->30| raise OSError("Some unknown message") 31| except OSError as e: OSError: OverflowError ------------- Generic ~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_overflow_error.py", line 6, in test_Generic 2.0 ** 1600 OverflowError: (34, 'Result too large') 'OverflowError' מוגבה כאשר התוצאה של פעולה חשבונית הוא גדול מכדי שניתן יהיה לטפל בו במעבד המחשב. Exception raised on line `6` of file 'TESTS:\runtime\test_overflow_error.py'. 4| def test_Generic(): 5| try: -->6| 2.0 ** 1600 ^^^^^^^^^^^ 7| except OverflowError as e: Huge lenght ~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_overflow_error.py", line 25, in test_Huge_lenght len(huge) OverflowError: Python int too large to convert to C ssize_t 'OverflowError' מוגבה כאשר התוצאה של פעולה חשבונית הוא גדול מכדי שניתן יהיה לטפל בו במעבד המחשב. Exception raised on line `25` of file 'TESTS:\runtime\test_overflow_error.py'. 22| def test_Huge_lenght(): 23| huge = range(1<<10000) 24| try: -->25| len(huge) ^^^^^^^^^ 26| except OverflowError as e: huge: range(0, ...) len(huge): Object too large to be processed by Python. len: RecursionError -------------- Generic ~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_recursion_error.py", line 8, in test_Generic a() ... שורות נוספות לא מוצגות. ... File "TESTS:\runtime\test_recursion_error.py", line 6, in a return a() File "TESTS:\runtime\test_recursion_error.py", line 6, in a return a() RecursionError: maximum recursion depth exceeded "RecursionError" מועלה כאשר פונקציה קוראת לעצמה, במישרין או בעקיפין, פעמים רבות מדי. זה כמעט תמיד מציין שעשית שגיאה בקוד שלך ושהתוכנית שלך לעולם לא תפסיק. Execution stopped on line `8` of file 'TESTS:\runtime\test_recursion_error.py'. 5| def a(): 6| return a() 7| try: -->8| a() ^^^ 9| except RecursionError as e: a: defined in Exception raised on line `6` of file 'TESTS:\runtime\test_recursion_error.py'. 5| def a(): -->6| return a() ^^^ a: defined in TypeError --------- Argument of object is not iterable ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 843, in test_Argument_of_object_is_not_iterable a in b TypeError: argument of type 'object' is not iterable 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. An iterable is an object capable of returning its members one at a time. Python containers (`list, tuple, dict`, etc.) are iterables. 'b' is not a container. A container is required here. Exception raised on line `843` of file 'TESTS:\runtime\test_type_error.py'. 840| a = object() 841| b = object() 842| try: -->843| a in b ^^^^^^ 844| except TypeError as e: a: b: Bad type for unary operator ~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 427, in test_Bad_type_for_unary_operator a =+ "def" TypeError: bad operand type for unary +: 'str' אולי התכוונת לכתוב `+=` במקום `=+` 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. ניסית להשתמש באופרטור האנורי '+' עם סוג האובייקט הבא: מחרוזת (`str`). פעולה זו אינה מוגדרת עבור אובייקט מסוג זה. אולי התכוונת לכתוב `+=` במקום `=+` Exception raised on line `427` of file 'TESTS:\runtime\test_type_error.py'. 422| assert "You tried to use the unary operator '~'" in result 423| 424| try: 425| # fmt: off 426| a = "abc" -->427| a =+ "def" ^^^^^^^ 428| # fmt: on Builtin has no len ~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 901, in test_Builtin_has_no_len len("Hello world".split) TypeError: object of type 'builtin_function_or_method' has no len() שכחת לקרוא ל '"Hello world".split'? 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. אני חושד ששכחת להוסיף סוגריים כדי לקרוא '"Hello world".split'. אולי התכוונת לכתוב: `len("Hello world".split())` Exception raised on line `901` of file 'TESTS:\runtime\test_type_error.py'. 899| def test_Builtin_has_no_len(): 900| try: -->901| len("Hello world".split) ^^^^^^^^^^^^^^^^^^^^^^^^ 902| except TypeError as e: len: "Hello world".split: Can only concatenate ~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 39, in test_Can_only_concatenate result = a_tuple + a_list TypeError: can only concatenate tuple (not "list") to tuple 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. ניסית לחבר (להוסיף) שני סוגים שונים של אובייקטים: צמד ('tuple') ו- רשימה (`list`). Exception raised on line `39` of file 'TESTS:\runtime\test_type_error.py'. 36| try: 37| a_tuple = (1, 2, 3) 38| a_list = [1, 2, 3] -->39| result = a_tuple + a_list ^^^^^^^^^^^^^^^^ 40| except TypeError as e: a_list: [1, 2, 3] a_tuple: (1, 2, 3) Cannot convert dictionary update sequence ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 886, in test_Cannot_convert_dictionary_update_sequence dd.update([1, 2, 3]) TypeError: cannot convert dictionary update sequence element #0 to a sequence Perhaps you need to use the `dict.fromkeys()` method. 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. `dict.update()` אינו מקבל רצף כארגומנט. במקום לכתוב 'dd.update([1, 2, 3])' אולי כדאי להשתמש בשיטת 'dict.fromkeys ()': "dd.update( dict.fromkeys([1, 2, 3]) )". (מילון.מהמפתחות(...)) Exception raised on line `886` of file 'TESTS:\runtime\test_type_error.py'. 882| assert "you should use the `dict.fromkeys()`" in result 883| 884| dd = {"a": "a"} 885| try: -->886| dd.update([1, 2, 3]) ^^^^^^^^^^^^^^^^^^^^ 887| except TypeError as e: dd: {'a': 'a'} dd.update: Cannot multiply by non int ~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 652, in test_Cannot_multiply_by_non_int "a" * "2" TypeError: can't multiply sequence by non-int of type 'str' שכחת להמיר את '"2"' למספר שלם? 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. אתה יכול רק להכפיל רצפים, כגון רשימה, זוגות, מחרוזות וכו ', לפי מספרים שלמים. אולי שכחת להמיר את '"2"' למספר שלם. Exception raised on line `652` of file 'TESTS:\runtime\test_type_error.py'. 648| if friendly_traceback.get_lang() == "en": 649| assert "Did you forget to convert `c` into an integer?" in result 650| 651| try: -->652| "a" * "2" ^^^^^^^^^ 653| except TypeError as e: Cannot unpack non iterable object ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 857, in test_Cannot_unpack_non_iterable_object a, b = 42.0 TypeError: cannot unpack non-iterable float object 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. פריקה היא דרך נוחה להקצות שם, לכל פריט של חוזר. חוזר הוא אובייקט המסוגל להחזיר את פרטיו,אחד בכל פעם. מכולות (`רשימה, tuple, dict`, וכו ') הם רכיבים חוזרים. אבל לא אובייקטים מהסוג `float`. Exception raised on line `857` of file 'TESTS:\runtime\test_type_error.py'. 855| def test_Cannot_unpack_non_iterable_object(): 856| try: -->857| a, b = 42.0 858| except TypeError as e: Cant mod complex numbers ~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 54, in test_Cant_mod_complex_numbers 3 + 3j % 2 TypeError: unsupported operand type(s) for %: 'complex' and 'int' 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. You cannot use complex numbers with the modulo operator `%`. Exception raised on line `54` of file 'TESTS:\runtime\test_type_error.py'. 52| def test_Cant_mod_complex_numbers(): 53| try: -->54| 3 + 3j % 2 ^^^^^^ 55| except TypeError as e: Comparison not supported ~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 375, in test_Comparison_not_supported b >= a TypeError: '>=' not supported between instances of 'int' and 'str' שכחת להמיר את המחרוזת "a" ל- מספר שלם (`int`)? 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. ניסית לבצע השוואת סדר (>=) בין שני סוגי אובייקטים לא תואמים: מספר שלם (`int`) ו- מחרוזת (`str`). אולי שכחת להמיר את המחרוזת "a" ל- מספר שלם (`int`). Exception raised on line `375` of file 'TESTS:\runtime\test_type_error.py'. 372| try: 373| a = "2" 374| b = 42 -->375| b >= a ^^^^^^ 376| except TypeError as e: a: '2' b: 42 Derive from BaseException ~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 594, in test_Derive_from_BaseException raise "exception" # noqa TypeError: exceptions must derive from BaseException 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. Exceptions must be derived from `BaseException`. It is recommended that user-defined exceptions derive from `Exception`, a subclass of `BaseException`. Exception raised on line `594` of file 'TESTS:\runtime\test_type_error.py'. 590| if friendly_traceback.get_lang() == "en": 591| assert "you must only have classes that derive from `BaseException`" in result 592| 593| try: -->594| raise "exception" # noqa 595| except TypeError as e: Generator has no len ~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 1062, in test_Generator_has_no_len nb = len(letter TypeError: object of type 'generator' has no len() You likely need to build a list first. 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. I am guessing that you were trying to count the number of elements produced by a generator expression. You first need to capture them in a list: len([letter for letter in "word"]) Exception raised on line `1062` of file 'TESTS:\runtime\test_type_error.py'. 1060| def test_Generator_has_no_len(): 1061| try: -->1062| nb = len(letter ^^^^^^^^^^ 1063| for letter in "word") ^^^^^^^^^^^^^^^^^^^^^ 1064| except TypeError as e: len: Indices must be integers or slices ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 736, in test_Indices_must_be_integers_or_slices [1, 2, 3]["2"] TypeError: list indices must be integers or slices, not str שכחת להמיר את '"2"' למספר שלם? 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. בביטוי `[1, 2, 3]["2"]` מה כלול בין הסוגריים המרובעים, '[...]', חייב להיות מספר שלם או פרוסה (`התחל: עצור` או` התחל: עצור: שלב`) והשתמשת במקום זאת ב- מחרוזת (`str`). אולי שכחת להמיר את '"2"' למספר שלם. Exception raised on line `736` of file 'TESTS:\runtime\test_type_error.py'. 732| if friendly_traceback.get_lang() == "en": 733| assert "Perhaps you forgot to convert `2.0` into an integer." in result 734| 735| try: -->736| [1, 2, 3]["2"] ^^^^^^^^^^^^^^ 737| except TypeError as e: Not an integer ~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 698, in test_Not_an_integer range(c, d) TypeError: 'str' object cannot be interpreted as an integer האם שכחת להמיר את 'c, d' למספרים שלמים? 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. כתבת אובייקט מסוג 'str' שבו צפוי מספר שלם. Perhaps you forgot to convert `c, d` into integers. Exception raised on line `698` of file 'TESTS:\runtime\test_type_error.py'. 694| assert "Perhaps you forgot to convert `1.0" in result 695| 696| c, d = "2", "3" 697| try: -->698| range(c, d) ^^^^^^^^^^^ 699| except TypeError as e: c: '2' d: '3' range: Not callable ~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 561, in test_Not_callable _ = [1, 2](a + b) TypeError: 'list' object is not callable האם התכוונת ל '[1, 2] [a + b]'? 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. בגלל הסוגריים שמסביב, '(a + b)' מתפרש על ידי פייתון כמעיד על קריאה לפונקציה `[1, 2]`, שהוא אובייקט מסוג 'list' שלא ניתן לקרוא לה. עם זאת, '[1, 2]' הוא רצף. אולי התכוונת להשתמש ב- [] במקום במקום () ולכתוב `[1, 2] [a + b]` Exception raised on line `561` of file 'TESTS:\runtime\test_type_error.py'. 557| assert "b.a_list[3]" in result 558| 559| try: 560| a, b = 3, 7 -->561| _ = [1, 2](a + b) ^^^^^^^^^^^^^ 562| except TypeError as e: a: 3 b: 7 a + b: 10 Object is not iterable ~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 826, in test_Object_is_not_iterable list(42) TypeError: 'int' object is not iterable 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. חוזר הוא אובייקט המסוגל להחזיר את פרטיו,אחד בכל פעם. מכולות (`רשימה, tuple, dict`, וכו ') הם רכיבים חוזרים. דרוש כאן חזרה. Exception raised on line `826` of file 'TESTS:\runtime\test_type_error.py'. 824| def test_Object_is_not_iterable(): 825| try: -->826| list(42) ^^^^^^^^ 827| except TypeError as e: list: Object is not subscriptable ~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 811, in test_Object_is_not_subscriptable a = f[1] TypeError: 'function' object is not subscriptable האם התכוונת ל "f(1)"? 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. אובייקטים הרשמים הם בדרך כלל מיכלים מהם אתה יכול לאחזר פריט באמצעות הסימון '[...]'. אולי התכוונת לכתוב 'f(1)'. Exception raised on line `811` of file 'TESTS:\runtime\test_type_error.py'. 807| def f(): 808| pass 809| 810| try: -->811| a = f[1] ^^^^ 812| except TypeError as e: f: defined in Slice indices must be integers or None ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 751, in test_Slice_indices_must_be_integers_or_None [1, 2, 3][1.0:2.0] TypeError: slice indices must be integers or None or have an __index__ method 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. בעת שימוש בפרוס (slice) לחילוץ מגוון אלמנטים מרצף, זה משהו כמו `[start: stop]` או `[start: stop: step]` כל אחד מ'התחלה ',' עצירה ',' שלב 'חייב להיות מספר שלם,' אין ', או אולי אובייקט אחר בעל שיטת '__index__'. Exception raised on line `751` of file 'TESTS:\runtime\test_type_error.py'. 749| def test_Slice_indices_must_be_integers_or_None(): 750| try: -->751| [1, 2, 3][1.0:2.0] ^^^^^^^^^^^^^^^^^^ 752| except TypeError as e: Too few positional argument ~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 500, in test_Too_few_positional_argument fn(1) TypeError: test_Too_few_positional_argument..fn() missing 2 required positional arguments: 'b' and 'c' 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. כנראה קראת לפונקציה 'test_Too_few_positional_argument..fn()' עם פחות ארגומנטים מיקוםיים ממה שהוא דורש (חסר 2). Exception raised on line `500` of file 'TESTS:\runtime\test_type_error.py'. 496| def fn(a, b, c): 497| pass 498| 499| try: -->500| fn(1) ^^^^^ 501| except TypeError as e: fn: defined in Too many positional argument ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 480, in test_Too_many_positional_argument A().f(1) TypeError: test_Too_many_positional_argument..A.f() takes 1 positional argument but 2 were given אולי שכחת את 'self'(עצמי) בהגדרת 'A.f'. 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. כנראה קראת לפונקציה 'A.f' עם 2 ארגומנטים בזמן שהוא דורש 1 ארגומנטים כאלה. אולי שכחת את 'self'(עצמי) בהגדרת 'A.f'. Exception raised on line `480` of file 'TESTS:\runtime\test_type_error.py'. 476| def f(x): 477| pass 478| 479| try: -->480| A().f(1) ^^^^^^^^ 481| except TypeError as e: A: defined in Tuple no item assignment ~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 446, in test_Tuple_no_item_assignment a[0] = 0 TypeError: 'tuple' object does not support item assignment האם התכוונת להשתמש ברשימה? 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. בפייתון כמה אובייקטים ידועים כבלתי משתנים: לאחר שהוגדר, לא ניתן לשנות את ערכם. ניסית לשנות חלק מאובייקט בלתי משתנה כזה: צמד ('tuple'), סביר להניח על ידי שימוש בפעולת אינדקס. אולי התכוונת להשתמש ברשימה במקום זאת. Exception raised on line `446` of file 'TESTS:\runtime\test_type_error.py'. 443| def test_Tuple_no_item_assignment(): 444| a = (1, 2, 3) 445| try: -->446| a[0] = 0 ^^^^ 447| except TypeError as e: a: (1, 2, 3) a[0]: 1 Unhachable type ~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 769, in test_Unhachable_type {[1, 2]: 1} TypeError: unhashable type: 'list' 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. ניתן להשתמש רק באובייקטים הניתנים לגיבוש כאלמנטים של 'סט' או כמקשים של 'dict'. אובייקטים ניתנים לגיבוש הם אובייקטים שאינם משנים ערך ברגע שהם נוצרו.במקום להשתמש ב- רשימה (`list`), שקול להשתמש ב- צמד ('tuple'). Exception raised on line `769` of file 'TESTS:\runtime\test_type_error.py'. 767| def test_Unhachable_type(): 768| try: -->769| {[1, 2]: 1} 770| except TypeError as e: Unsupported operand types ~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 325, in test_Unsupported_operand_types a @= b TypeError: unsupported operand type(s) for @=: 'str' and 'int' 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. ניסית להשתמש באופרטור @= שימוש בשני סוגים של אובייקטים לא תואמים: מחרוזת (`str`) ו- מספר שלם (`int`). מפעיל זה משמש בדרך כלל בלבד לריבוי מטריצות. Exception raised on line `325` of file 'TESTS:\runtime\test_type_error.py'. 322| try: 323| a = "a" 324| b = 2 -->325| a @= b 326| except TypeError as e: a: 'a' b: 2 divmod ~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 69, in test_divmod result = divmod(a, b) TypeError: unsupported operand type(s) for divmod(): 'int' and 'complex' 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. The arguments of `divmod` must be integers (`int`) or real (`float`) numbers. At least one of the arguments was a complex number. Exception raised on line `69` of file 'TESTS:\runtime\test_type_error.py'. 66| a = 2 67| b = 3 + 2j 68| try: -->69| result = divmod(a, b) ^^^^^^^^^^^^ 70| except TypeError as e: a: 2 b: (3+2j) divmod: function got multiple argument ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 996, in test_function_got_multiple_argument fn2(0, a=1) TypeError: test_function_got_multiple_argument..fn2() got multiple values for argument 'a' 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. You have specified the value of argument `a` more than once when calling the function named `fn2`. This function has the following arguments: `a, b=1` Exception raised on line `996` of file 'TESTS:\runtime\test_type_error.py'. 992| def fn2(a, b=1): 993| pass 994| 995| try: -->996| fn2(0, a=1) ^^^^^^^^^^^ 997| except TypeError as e: fn2: defined in function has no len ~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 919, in test_function_has_no_len len(bad) TypeError: object of type 'function' has no len() שכחת לקרוא ל 'bad'? 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. אני חושד ששכחת להוסיף סוגריים כדי לקרוא 'bad'. אולי התכוונת לכתוב: `len(bad())` Exception raised on line `919` of file 'TESTS:\runtime\test_type_error.py'. 915| def bad(): 916| pass 917| 918| try: -->919| len(bad) ^^^^^^^^ 920| except TypeError as e: bad: defined in len: getattr attribute name must be string ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 1044, in test_getattr_attribute_name_must_be_string getattr("__repr__", 1) # as reported in issue #77 TypeError: getattr(): attribute name must be string 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. The second argument of the function `getattr()` must be a string. Exception raised on line `1044` of file 'TESTS:\runtime\test_type_error.py'. 1037| if friendly_traceback.get_lang() == "en": 1038| assert ( 1039| "The second argument of the function `hasattr()` must be a string." 1040| in result 1041| ) 1042| 1043| try: -->1044| getattr("__repr__", 1) # as reported in issue #77 ^^^^^^^^^^^^^^^^^^^^^^ 1045| except TypeError as e: getattr: method got multiple argument ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 1016, in test_method_got_multiple_argument t.some_method(0, a=1) TypeError: test_method_got_multiple_argument..T.some_method() got multiple values for argument 'a' 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. You have specified the value of argument `a` more than once when calling the function named `t.some_method`. This function has only one argument: `a` Exception raised on line `1016` of file 'TESTS:\runtime\test_type_error.py'. 1012| pass 1013| 1014| t = T() 1015| try: -->1016| t.some_method(0, a=1) ^^^^^^^^^^^^^^^^^^^^^ 1017| except TypeError as e: t: defined in t.some_method: of defined in vars arg must have dict ~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_type_error.py", line 964, in test_vars_arg_must_have_dict vars(f) TypeError: vars() argument must have __dict__ attribute 'TypeError' נגרמת בדרך כלל על ידי ניסיון לשלב שני סוגי אובייקטים שאינם תואמים, על ידי קריאה לפונקציה עם סוג האובייקט הלא נכון, או על ידי ניסיון לבצע פעולה שאינה מותרת בסוג נתון של אובייקט. The function `vars` is used to list the content of the `__dict__` attribute of an object. Object `f` uses `__slots__` instead of `__dict__`. Exception raised on line `964` of file 'TESTS:\runtime\test_type_error.py'. 960| assert no_slots not in result 961| assert use_slots not in result 962| 963| try: -->964| vars(f) ^^^^^^^ 965| except TypeError as e: f: defined in vars: UnboundLocalError ----------------- Missing both ~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_unbound_local_error.py", line 65, in test_Missing_both outer_missing_both() File "TESTS:\runtime\test_unbound_local_error.py", line 22, in outer_missing_both inner() File "TESTS:\runtime\test_unbound_local_error.py", line 21, in inner spam_missing_both += 1 UnboundLocalError: local variable 'spam_missing_both' referenced before assignment שכחת להוסיף את 'global spam_missing_both' או `לא -מקומי spam_missing_both`? ב-Python, משתנים המשמשים בתוך פונקציה ידועים בשם משתנים מקומיים. לפני השימוש בהם, יש להקצות להם ערך. מניחים למשתנה שמשתמשים בו לפני שהוקצה לו ערך להיות מוגדר מחוץ לפונקציה זו; זה ידוע בתור 'גלובלי' (או לפעמים 'לא מקומי'). אתה לא יכול להקצות ערך לכאלה משתנה גלובלי בתוך פונקציה מבלי לציין תחילה ל פייתון שזה משתנה גלובלי, אחרת תראה 'UnboundLocalError'. You're trying to use the name `spam_missing_both` identified by Python as being in the local scope of a function before having assigned it a value. השם "spam_missing_both" קיים גם בתחום הגלובלי וגם הלא -מקומי. זה יכול להיות די מבלבל ואינו מומלץ. תלוי לאיזה משתנה אתה רוצה להתייחס, היית צריך להוסיף את זה spam_missing_both גלובלי אוֹ spam_missing_both לא -מקומי כשורה הראשונה בתוך הפונקציה שלך. Execution stopped on line `65` of file 'TESTS:\runtime\test_unbound_local_error.py'. 63| def test_Missing_both(): 64| try: -->65| outer_missing_both() ^^^^^^^^^^^^^^^^^^^^ 66| except UnboundLocalError as e: global outer_missing_both: Exception raised on line `21` of file 'TESTS:\runtime\test_unbound_local_error.py'. 20| def inner(): -->21| spam_missing_both += 1 global spam_missing_both: 1 Missing global ~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_unbound_local_error.py", line 27, in test_Missing_global outer_missing_global() File "TESTS:\runtime\test_unbound_local_error.py", line 10, in outer_missing_global inner() File "TESTS:\runtime\test_unbound_local_error.py", line 9, in inner spam_missing_global += 1 UnboundLocalError: local variable 'spam_missing_global' referenced before assignment שכחת להוסיף את 'global spam_missing_global'? ב-Python, משתנים המשמשים בתוך פונקציה ידועים בשם משתנים מקומיים. לפני השימוש בהם, יש להקצות להם ערך. מניחים למשתנה שמשתמשים בו לפני שהוקצה לו ערך להיות מוגדר מחוץ לפונקציה זו; זה ידוע בתור 'גלובלי' (או לפעמים 'לא מקומי'). אתה לא יכול להקצות ערך לכאלה משתנה גלובלי בתוך פונקציה מבלי לציין תחילה ל פייתון שזה משתנה גלובלי, אחרת תראה 'UnboundLocalError'. You're trying to use the name `spam_missing_global` identified by Python as being in the local scope of a function before having assigned it a value. The name `spam_missing_global` exists in the global scope. Perhaps the statement global spam_missing_global should have been included as the first line inside your function. Execution stopped on line `27` of file 'TESTS:\runtime\test_unbound_local_error.py'. 25| def test_Missing_global(): 26| try: -->27| outer_missing_global() ^^^^^^^^^^^^^^^^^^^^^^ 28| except UnboundLocalError as e: global outer_missing_global: Exception raised on line `9` of file 'TESTS:\runtime\test_unbound_local_error.py'. 8| def inner(): -->9| spam_missing_global += 1 global spam_missing_global: 1 Missing nonlocal ~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_unbound_local_error.py", line 46, in test_Missing_nonlocal outer_missing_nonlocal() File "TESTS:\runtime\test_unbound_local_error.py", line 16, in outer_missing_nonlocal inner() File "TESTS:\runtime\test_unbound_local_error.py", line 15, in inner spam_missing_nonlocal += 1 UnboundLocalError: local variable 'spam_missing_nonlocal' referenced before assignment שכחת להוסיף את 'nonlocal spam_missing_nonlocal'? ב-Python, משתנים המשמשים בתוך פונקציה ידועים בשם משתנים מקומיים. לפני השימוש בהם, יש להקצות להם ערך. מניחים למשתנה שמשתמשים בו לפני שהוקצה לו ערך להיות מוגדר מחוץ לפונקציה זו; זה ידוע בתור 'גלובלי' (או לפעמים 'לא מקומי'). אתה לא יכול להקצות ערך לכאלה משתנה גלובלי בתוך פונקציה מבלי לציין תחילה ל פייתון שזה משתנה גלובלי, אחרת תראה 'UnboundLocalError'. You're trying to use the name `spam_missing_nonlocal` identified by Python as being in the local scope of a function before having assigned it a value. The name `spam_missing_nonlocal` exists in the nonlocal scope. Perhaps the statement nonlocal spam_missing_nonlocal should have been included as the first line inside your function. Execution stopped on line `46` of file 'TESTS:\runtime\test_unbound_local_error.py'. 44| def test_Missing_nonlocal(): 45| try: -->46| outer_missing_nonlocal() ^^^^^^^^^^^^^^^^^^^^^^^^ 47| except UnboundLocalError as e: global outer_missing_nonlocal: Exception raised on line `15` of file 'TESTS:\runtime\test_unbound_local_error.py'. 14| def inner(): -->15| spam_missing_nonlocal += 1 Typo in local ~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_unbound_local_error.py", line 104, in test_Typo_in_local test2() File "TESTS:\runtime\test_unbound_local_error.py", line 101, in test2 alpha3 += 1 UnboundLocalError: local variable 'alpha3' referenced before assignment האם התכוונת ל 'alpha1'? ב-Python, משתנים המשמשים בתוך פונקציה ידועים בשם משתנים מקומיים. לפני השימוש בהם, יש להקצות להם ערך. מניחים למשתנה שמשתמשים בו לפני שהוקצה לו ערך להיות מוגדר מחוץ לפונקציה זו; זה ידוע בתור 'גלובלי' (או לפעמים 'לא מקומי'). אתה לא יכול להקצות ערך לכאלה משתנה גלובלי בתוך פונקציה מבלי לציין תחילה ל פייתון שזה משתנה גלובלי, אחרת תראה 'UnboundLocalError'. במקום לכתוב 'alpha3', אולי התכוונת לאחד מהדברים הבאים: * היקף מקומי `alpha1`, `alpha2` Execution stopped on line `104` of file 'TESTS:\runtime\test_unbound_local_error.py'. 100| alpha2 = 1 101| alpha3 += 1 102| 103| try: -->104| test2() ^^^^^^^ 105| except UnboundLocalError as e: test2: defined in Exception raised on line `101` of file 'TESTS:\runtime\test_unbound_local_error.py'. 98| def test2(): 99| alpha1 = 1 100| alpha2 = 1 -->101| alpha3 += 1 Using name of builtin ~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_unbound_local_error.py", line 125, in test_Using_name_of_builtin dist([]) File "TESTS:\runtime\test_unbound_local_error.py", line 121, in dist max = max(points) UnboundLocalError: local variable 'max' referenced before assignment ב-Python, משתנים המשמשים בתוך פונקציה ידועים בשם משתנים מקומיים. לפני השימוש בהם, יש להקצות להם ערך. מניחים למשתנה שמשתמשים בו לפני שהוקצה לו ערך להיות מוגדר מחוץ לפונקציה זו; זה ידוע בתור 'גלובלי' (או לפעמים 'לא מקומי'). אתה לא יכול להקצות ערך לכאלה משתנה גלובלי בתוך פונקציה מבלי לציין תחילה ל פייתון שזה משתנה גלובלי, אחרת תראה 'UnboundLocalError'. `max` is a Python builtin function. You have tried to assign a value to `max` inside a function while also using its original meaning in the function. Note that it is generally not a good idea to give a local variable the same name as a Python builtin function (like `max`). Execution stopped on line `125` of file 'TESTS:\runtime\test_unbound_local_error.py'. 122| min = min(points) 123| return max - min 124| try: -->125| dist([]) ^^^^^^^^ 126| except UnboundLocalError as e: dist: defined in Exception raised on line `121` of file 'TESTS:\runtime\test_unbound_local_error.py'. 120| def dist(points): -->121| max = max(points) ^^^ 122| min = min(points) max: UnknownError ------------ Generic ~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_unknown_error.py", line 24, in test_Generic raise UnknownException("Some informative message about an unknown exception.") UnknownException: Some informative message about an unknown exception. שגיאה מסוג `UnknownException` היא תת-מחלקה של `Exception`. Nothing more specific is known about `UnknownException`. All built-in exceptions defined by Python are derived from `Exception`. All user-defined exceptions should also be derived from this class. Exception raised on line `24` of file 'TESTS:\runtime\test_unknown_error.py'. 20| result = friendly_traceback.get_output() 21| assert "UnknownException -> Exception" in result 22| 23| try: -->24| raise UnknownException("Some informative message about an unknown exception.") 25| except Exception as e: global UnknownException: ValueError ---------- Convert to int ~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_value_error.py", line 194, in test_Convert_to_int int('13a') ValueError: invalid literal for int() with base 10: '13a' 'ValueError' מציין כי פונקציה או פעולה קיבל ערך מהסוג הנכון, אך בעל ערך לא נכון. `'13a'` הוא ארגומנט לא חוקי עבור `int (שלם)` בבסיס `10`. בבסיס '10', 'int (שלם)' משמש לרוב להמרת מחרוזת המכיל את הספרות '0' עד '9' למספר שלם. The following characters are not allowed: `a`. Exception raised on line `194` of file 'TESTS:\runtime\test_value_error.py'. 190| if english: 191| assert "needs to be first converted using `float()`" in result 192| 193| try: -->194| int('13a') ^^^^^^^^^^ 195| except ValueError as e: int: Could not convert to float ~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_value_error.py", line 92, in test_Could_not_convert_to_float float("42b") ValueError: could not convert string to float: '42b' 'ValueError' מציין כי פונקציה או פעולה קיבל ערך מהסוג הנכון, אך בעל ערך לא נכון. The string `42b` cannot be converted to a `float` as it does not represent a number. Exception raised on line `92` of file 'TESTS:\runtime\test_value_error.py'. 90| def test_Could_not_convert_to_float(): 91| try: -->92| float("42b") ^^^^^^^^^^^^ 93| except ValueError as e: float: Date invalid month ~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_value_error.py", line 60, in test_Date_invalid_month d = date(2021, 13, 1) ValueError: month must be in 1..12 האם ציינת חודש לא חוקי? 'ValueError' מציין כי פונקציה או פעולה קיבל ערך מהסוג הנכון, אך בעל ערך לא נכון. אני מנחש שאתה מציין ערך לא חוקי למשך חודש באובייקט `תאריך`. ערכים חוקיים הם מספרים שלמים, מ -1 עד 12. Exception raised on line `60` of file 'TESTS:\runtime\test_value_error.py'. 57| def test_Date_invalid_month(): 58| from datetime import date 59| try: -->60| d = date(2021, 13, 1) ^^^^^^^^^^^^^^^^^ 61| except ValueError as e: date: Not enough values to unpack ~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_value_error.py", line 28, in test_Not_enough_values_to_unpack a, b, c = d ValueError: not enough values to unpack (expected 3, got 2) 'ValueError' מציין כי פונקציה או פעולה קיבל ערך מהסוג הנכון, אך בעל ערך לא נכון. פריקה היא דרך נוחה להקצות שם, לכל פריט של חוזר. במקרה זה, ישנם שמות נוספים (3) מאשר אורך ה- iterable, מחרוזת (`str`) של אורך 2. Exception raised on line `28` of file 'TESTS:\runtime\test_value_error.py'. 24| assert "ValueError: not enough values to unpack (expected 3, got 2)" in result 25| 26| d = "ab" 27| try: -->28| a, b, c = d 29| except ValueError as e: d: 'ab' Pow third arg cannot be zero ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_value_error.py", line 108, in test_Pow_third_arg_cannot_be_zero pow(2, 4, a) ValueError: pow() 3rd argument cannot be 0 'ValueError' מציין כי פונקציה או פעולה קיבל ערך מהסוג הנכון, אך בעל ערך לא נכון. The third argument of the function `pow()` cannot be zero. Exception raised on line `108` of file 'TESTS:\runtime\test_value_error.py'. 105| def test_Pow_third_arg_cannot_be_zero(): 106| a = 0 107| try: -->108| pow(2, 4, a) ^^^^^^^^^^^^ 109| except ValueError as e: a: 0 pow: Slots conflicts with class variable ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_value_error.py", line 75, in test_Slots_conflicts_with_class_variable class F: ValueError: 'a' in __slots__ conflicts with class variable 'ValueError' מציין כי פונקציה או פעולה קיבל ערך מהסוג הנכון, אך בעל ערך לא נכון. The name `a` is used both as the name of a class variable and as a string item in the class `__slots__`; this is not allowed. Exception raised on line `75` of file 'TESTS:\runtime\test_value_error.py'. 73| def test_Slots_conflicts_with_class_variable(): 74| try: -->75| class F: 76| __slots__ = ["a", "b"] Too many values to unpack ~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_value_error.py", line 44, in test_Too_many_values_to_unpack a, b = c ValueError: too many values to unpack (expected 2) 'ValueError' מציין כי פונקציה או פעולה קיבל ערך מהסוג הנכון, אך בעל ערך לא נכון. פריקה היא דרך נוחה להקצות שם, לכל פריט של חוזר. במקרה זה, יש פחות שמות (2) מאשר אורך ה- iterable, רשימה (`list`) של אורך 3. Exception raised on line `44` of file 'TESTS:\runtime\test_value_error.py'. 41| def test_Too_many_values_to_unpack(): 42| c = [1, 2, 3] 43| try: -->44| a, b = c 45| except ValueError as e: c: [1, 2, 3] int base not in range ~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_value_error.py", line 209, in test_int_base_not_in_range int('18', base=37) ValueError: int() base must be >= 2 and <= 36, or 0 'ValueError' מציין כי פונקציה או פעולה קיבל ערך מהסוג הנכון, אך בעל ערך לא נכון. The argument `base` of `int()` must be either zero or any integer from 2 to 36. You wrote 37 which is not allowed. Exception raised on line `209` of file 'TESTS:\runtime\test_value_error.py'. 207| def test_int_base_not_in_range(): 208| try: -->209| int('18', base=37) ^^^^^^^^^^^^^^^^^^ 210| except ValueError as e: int: remove item not in list ~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_value_error.py", line 236, in test_remove_item_not_in_list a_list.remove(b) ValueError: list.remove(x): x not in list 'ValueError' מציין כי פונקציה או פעולה קיבל ערך מהסוג הנכון, אך בעל ערך לא נכון. You have attempted to remove `b` from the list `a_list`. However, `a_list` does not contain `b`. Exception raised on line `236` of file 'TESTS:\runtime\test_value_error.py'. 233| a_list = [1, 2, 3] 234| b = 4 235| try: -->236| a_list.remove(b) ^^^^^^^^^^^^^^^^ 237| except ValueError as e: a_list: [1, 2, 3] b: 4 a_list.remove: time strptime incorrect format ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_value_error.py", line 133, in test_time_strptime_incorrect_format time.strptime("2020-01-01", "%d %m %Y") ValueError: time data '2020-01-01' does not match format '%d %m %Y' 'ValueError' מציין כי פונקציה או פעולה קיבל ערך מהסוג הנכון, אך בעל ערך לא נכון. The value you gave for the time is not in the format you specified. Make sure to use the same separator between items (for example, between day and month) and keep the order the same in both the data provided and the format you specified. The following table might be useful: https://docs.python.org/3/library/time.html#time.strftime The following site might also be useful: https://www.strfti.me/ Exception raised on line `133` of file 'TESTS:\runtime\test_value_error.py'. 129| return 130| 131| import time 132| try: -->133| time.strptime("2020-01-01", "%d %m %Y") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 134| except ValueError as e: time: time.strptime: ZeroDivisionError ----------------- Complex division ~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_zero_division_error.py", line 180, in test_Complex_division 1 / zero ZeroDivisionError: complex division by zero 'ZeroDivisionError' מתרחש כאשר אתה מנסה לחלק ערך באפס ישירות או באמצעות פעולה מתמטית אחרת. את\ה מחלק\תבמונח הבא zero שהוא שווה לאפס. Exception raised on line `180` of file 'TESTS:\runtime\test_zero_division_error.py'. 177| def test_Complex_division(): 178| zero = 0j 179| try: -->180| 1 / zero ^^^^^^^^ 181| except ZeroDivisionError as e: zero: 0j Division by zero literal ~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_zero_division_error.py", line 229, in test_Division_by_zero_literal 1.0 / 0 ZeroDivisionError: float division by zero 'ZeroDivisionError' מתרחש כאשר אתה מנסה לחלק ערך באפס ישירות או באמצעות פעולה מתמטית אחרת. את\ה מחלק\ת באפס. Exception raised on line `229` of file 'TESTS:\runtime\test_zero_division_error.py'. 225| if friendly_traceback.get_lang() == "en": 226| assert "Using the modulo operator, `%`, you are dividing by zero" in result 227| 228| try: -->229| 1.0 / 0 ^^^^^^^ 230| except ZeroDivisionError as e: Division operator ~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_zero_division_error.py", line 20, in test_Division_operator 1 / zero ZeroDivisionError: division by zero 'ZeroDivisionError' מתרחש כאשר אתה מנסה לחלק ערך באפס ישירות או באמצעות פעולה מתמטית אחרת. את\ה מחלק\תבמונח הבא zero שהוא שווה לאפס. Exception raised on line `20` of file 'TESTS:\runtime\test_zero_division_error.py'. 13| if friendly_traceback.get_lang() == "en": 14| assert ( 15| "The following mathematical expression includes a division by zero" 16| in result 17| ) 18| 19| try: -->20| 1 / zero ^^^^^^^^ 21| except ZeroDivisionError as e: zero: 0 Divmod ~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_zero_division_error.py", line 100, in test_Divmod divmod(1, zero) ZeroDivisionError: integer division or modulo by zero 'ZeroDivisionError' מתרחש כאשר אתה מנסה לחלק ערך באפס ישירות או באמצעות פעולה מתמטית אחרת. הטיעון השני של הפונקציה `divmod(חלוקה)` הוא אפס. Exception raised on line `100` of file 'TESTS:\runtime\test_zero_division_error.py'. 97| def test_Divmod(): 98| zero = 0 99| try: -->100| divmod(1, zero) ^^^^^^^^^^^^^^^ 101| except ZeroDivisionError as e: zero: 0 divmod: Float division ~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_zero_division_error.py", line 148, in test_Float_division 1 / zero ZeroDivisionError: float division by zero 'ZeroDivisionError' מתרחש כאשר אתה מנסה לחלק ערך באפס ישירות או באמצעות פעולה מתמטית אחרת. את\ה מחלק\תבמונח הבא zero שהוא שווה לאפס. Exception raised on line `148` of file 'TESTS:\runtime\test_zero_division_error.py'. 145| def test_Float_division(): 146| zero = 0.0 147| try: -->148| 1 / zero ^^^^^^^^ 149| except ZeroDivisionError as e: zero: 0.0 Float divmod ~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_zero_division_error.py", line 164, in test_Float_divmod divmod(1, zero) ZeroDivisionError: float divmod() 'ZeroDivisionError' מתרחש כאשר אתה מנסה לחלק ערך באפס ישירות או באמצעות פעולה מתמטית אחרת. הטיעון השני של הפונקציה `divmod(חלוקה)` שווה אפס. Exception raised on line `164` of file 'TESTS:\runtime\test_zero_division_error.py'. 161| def test_Float_divmod(): 162| zero = 0.0 163| try: -->164| divmod(1, zero) ^^^^^^^^^^^^^^^ 165| except ZeroDivisionError as e: zero: 0.0 divmod: Float modulo ~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_zero_division_error.py", line 132, in test_Float_modulo 1 % zero ZeroDivisionError: float modulo 'ZeroDivisionError' מתרחש כאשר אתה מנסה לחלק ערך באפס ישירות או באמצעות פעולה מתמטית אחרת. Using the modulo operator, `%`, you are dividing by the following term zero which is equal to zero. Exception raised on line `132` of file 'TESTS:\runtime\test_zero_division_error.py'. 125| assert ( 126| "The following mathematical expression includes a division by zero" 127| in result 128| ) 129| assert "done using the modulo operator" in result 130| 131| try: -->132| 1 % zero ^^^^^^^^ 133| except ZeroDivisionError as e: zero: 0.0 Integer division operator ~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_zero_division_error.py", line 49, in test_Integer_division_operator 1 // zero ZeroDivisionError: integer division or modulo by zero 'ZeroDivisionError' מתרחש כאשר אתה מנסה לחלק ערך באפס ישירות או באמצעות פעולה מתמטית אחרת. את\ה מחלק\תבמונח הבא zero שהוא שווה לאפס. Exception raised on line `49` of file 'TESTS:\runtime\test_zero_division_error.py'. 42| if friendly_traceback.get_lang() == "en": 43| assert ( 44| "The following mathematical expression includes a division by zero" 45| in result 46| ) 47| 48| try: -->49| 1 // zero ^^^^^^^^^ 50| except ZeroDivisionError as e: zero: 0 Mixed operations ~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_zero_division_error.py", line 243, in test_Mixed_operations a = divmod(8, 1 // 2) ZeroDivisionError: integer division or modulo by zero 'ZeroDivisionError' מתרחש כאשר אתה מנסה לחלק ערך באפס ישירות או באמצעות פעולה מתמטית אחרת. הביטוי המתמטי הבא כולל חלוקה באפס: divmod(8, 1 // 2) Exception raised on line `243` of file 'TESTS:\runtime\test_zero_division_error.py'. 241| def test_Mixed_operations(): 242| try: -->243| a = divmod(8, 1 // 2) ^^^^^^^^^^^^^^^^^ 244| except ZeroDivisionError as e: divmod: 1 // 2: 0 Modulo operator ~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_zero_division_error.py", line 81, in test_Modulo_operator 1 % zero ZeroDivisionError: integer division or modulo by zero 'ZeroDivisionError' מתרחש כאשר אתה מנסה לחלק ערך באפס ישירות או באמצעות פעולה מתמטית אחרת. Using the modulo operator, `%`, you are dividing by the following term zero which is equal to zero. Exception raised on line `81` of file 'TESTS:\runtime\test_zero_division_error.py'. 74| if friendly_traceback.get_lang() == "en": 75| assert ( 76| "The following mathematical expression includes a division by zero" 77| in result 78| ) 79| 80| try: -->81| 1 % zero ^^^^^^^^ 82| except ZeroDivisionError as e: zero: 0 Raise zero negative power ~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: none Traceback (most recent call last): File "TESTS:\runtime\test_zero_division_error.py", line 196, in test_Raise_zero_negative_power zero**-1 ZeroDivisionError: 0.0 cannot be raised to a negative power 'ZeroDivisionError' מתרחש כאשר אתה מנסה לחלק ערך באפס ישירות או באמצעות פעולה מתמטית אחרת. את\ה מנסה להעלות את המספר 0 בחזקת מספר שלילי זה מקביל לחלוקה באפס. Exception raised on line `196` of file 'TESTS:\runtime\test_zero_division_error.py'. 193| def test_Raise_zero_negative_power(): 194| zero = 0 195| try: -->196| zero**-1 ^^^^^^^^ 197| except ZeroDivisionError as e: zero: 0