Understanding how Python “Compiles” or “Interprets” Function Objects

后端 未结 2 674
耶瑟儿~
耶瑟儿~ 2021-01-28 18:06

I have read the following posts but I am still unsure of something.

  1. Python Compilation/Interpretation Process

  2. Why python compile the source to b

2条回答
  •  萌比男神i
    2021-01-28 18:44

    mgilson got half of the answer.

    The other half is that Python doesn't go looking for errors beyond syntax errors in functions (or function objects) it is not about to execute. So in the first case, since f() doesn't get called, the order-of-operations error isn't checked for.

    In this respect, it is not like C and C++, which require everything to be fully declared up front. It's kind of like C++ templates, where errors in template code might not be found until the code is actually instantiated.

提交回复
热议问题