Search code examples
listcythonkeywordreserved-wordsreserved

Can I have a list of the reserved words and keywords used in Cython?


I'm looking for the list of reserved words and keywords that are used in Cython, can anybody point me to the right direction?

If anybody is wondering why I'm asking for these, it's because I will be using it for our comparative study among three programming languages, namely, Cobra, Cython, and Euclid (which is totally difficult to find, help as well?).

Mind you, I've checked their official website and the documentation included with it. Although I haven't read the documentation thoroughly, I did perform a quick search, but no list came up.


Any help would be greatly appreciated, thanks!


EDIT: URL for the documentation.


Solution

  • Keywords for python is a remarkably short list

    In [100]: import keyword
    In [101]: keyword.kwlist
    Out[101]: 
    ['False',
     'None',
     'True',
     'and',
     'as',
     'assert',
     'break',
     'class',
     'continue',
     'def',
     'del',
     'elif',
     'else',
     'except',
     'finally',
     'for',
     'from',
     'global',
     'if',
     'import',
     'in',
     'is',
     'lambda',
     'nonlocal',
     'not',
     'or',
     'pass',
     'raise',
     'return',
     'try',
     'while',
     'with',
     'yield']
    

    Things like bool, int, float, list are not keywords. They are builtin functions. They are variables, and the user can reassign them. We see for example beginners writing:

     list = [1,2,3]
    

    and then wondering why list(...) returns an error.

    cython/docs/sphinxext/cython_highlighting.py - the file for documentation highlighting might be useful. It has lists of keywords and builtins.

    cython/Cython/Parser/Grammar - though this cautions: "This grammar is not yet used by the Cython parser and is subject to change."