Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Actually, it is a runtime error, because Python will try to resolve the <code>flt</code> name during runtime (because it's a dynamic language), and it won't find it. When this happens, Python yields and exception saying that it couldn't find the symbol you were using <code>flt</code> and all this happens at runtime.</p> <p>Syntax errors happen when the interpreter find something not compelling with Python's syntax. For example: The Python's grammar doesn't recognize the input syntax as a valid Python program. This may happen when:</p> <ol> <li>You forgot to add <code>:</code> at the end of an <code>if, def, class</code>, etc expression </li> <li>You forgot to close some parenthesis or brackets, etc.</li> <li>A lot of places else when you don't adhere to python's grammar :)</li> </ol> <p>In your example, there is nothing wrong with the grammar. For the interpreter, <code>flt(i)</code> is a very valid call to a <code>flt</code> method which had to be check at runtime within the scopes if it really exists. So the interpreter won't complaint and the syntax of your problem is good.</p> <p>Actually, this can be seen as a disadvantage over <em>compiled languages</em> like C#, C++, etc. This kind of errors can be detected sooner at compile time, and the compiler screams loud when it find it so you can notice it.</p> <p>With dynamic languages, you won't notice this until the actual method is called. Your program is simple, so you may find it quick. But, what about the missing <code>o</code> in <code>float</code> was inside some legacy framework within a subclass of a subclass of a class, as a property, inside some other module, etc. That would be harsh :)</p> <p><strong>UPDATE:</strong> <a href="http://docs.python.org/2/reference/executionmodel.html" rel="noreferrer">The execution model</a> in Python's docs are a great read if you're into how does Python internals works. This will clarify your doubt further and will give you a lot of knowledge :)</p> <p>Hope this helps!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload