-1

My question is Python specific (3.4.3). My question is specific to Built-In functions only.

It is clear to me the difference between a keyword (reserved word) and an identifier (user-defined variable). See: https://en.wikipedia.org/wiki/Reserved_word

Likewise, I understand the basic meaning of the terminology 'function' See : https://en.wikipedia.org/wiki/Functional_programming \ and http://www.learnpython.org/en/Functions

However, I am having difficulty understanding the difference between Built-in functions and keywords; such as 'if' and 'for'. https://docs.python.org/3/library/functions.html#built-in-funcs

What is the difference between the two? Keyword and Function.

Is the Keyword 'if' not simply a built in function? If so, why does it not appear in the official list of Built-In functions in the Python documentation? https://docs.python.org/3/library/functions.html#built-in-funcs

It certainly behaves as a function. Is it simply because it preforms a procedure as opposed to returning a value? In which case how would you define it? As a method?

I have searched high and low on stackoverflow and I cannot seem to locate an answer.

Answers such as the two examples given below do not answer the overriding questions for me. Which are;

1) What defines a keyword as a keyword, rather than a builtIn function? 2) If keywords such as 'if' are not functions, then what are they? They are not classes etc. I understand that 'IF' is an example of a condition statement but what is the generic terminology for these keywords. The word keyword only defines the fact that it is reserved within the language, it does not define what the actual object is, i.e. function, class, method etc.

http://stackoverflow.com/questions/6054672/whats-the-difference-between-a-keyword-or-a-statement-and-a-function-call
http://stackoverflow.com/questions/155609/difference-between-a-method-and-a-function?rq=1
Andrew Hardiman
  • 929
  • 1
  • 15
  • 30
  • 1
    Keywords do not behave as functions. Individual functions do not have dedicated syntax. Keywords are the blocks from which the operations of functions must be built. Functions can be redefined. Try writing a function that duplicates `if` without using `if`. – khelwood Dec 13 '15 at 13:11
  • 1
    See https://docs.python.org/2/reference/lexical_analysis.html#identifiers – jonrsharpe Dec 13 '15 at 13:27

1 Answers1

1

Keywords are those that describe the action to be performed, or specify how to interpret something (give meaning to instructions)

Functions are simply labels (for a set of instructions).

If you change function names it won't matter to Python (you can edit built in modules), but you can't relabel keywords.

You have already added tons of references to both, so I will not cite more.

xyz
  • 3,349
  • 1
  • 23
  • 29