0

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.

  • I'd prefer if it was just the list of reserved words and keywords, like 'short,' 'int,' 'for,' and so on. :) – IneptGamer02 Sep 26 '16 at 11:51
  • Possible duplicate of [Is it possible to get a list of keywords in Python?](http://stackoverflow.com/questions/9642087/is-it-possible-to-get-a-list-of-keywords-in-python) – Chris_Rands Sep 26 '16 at 11:53
  • Are all keywords and reserved words in Cython exactly the same with Python's? – IneptGamer02 Sep 26 '16 at 11:56
  • `cython` recognizes most, if not all, of `python`, but does add some of its own keywords, often with a `c` prefix, e.g. `cdef`, `cpdef`, etc. What does the `cython` docs say about interpreting `python`? – hpaulj Sep 26 '16 at 15:51
  • @hpaulj, then can you orient me on where I could view that list? I do know that Cython also added some keywords from C, like the 'signed,' keyword. Your help would be greatly appreciated! :) – IneptGamer02 Sep 26 '16 at 15:59
  • http://docs.cython.org/en/latest/src/reference/language_basics.html is a starting point; I don't know of a neat list that you can print and compare with another language. – hpaulj Sep 26 '16 at 16:08
  • I've already been there, but there isn't any list or whatsoever, the only thing I could probably do is read every article on that documentation page, only to find out that I'm missing some important keywords. :( – IneptGamer02 Sep 26 '16 at 16:22

1 Answers1

1

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."

hpaulj
  • 221,503
  • 14
  • 230
  • 353
  • Oh, thank you very much. But the thing I'm wondering about is that if this all Cython's keywords and RW's, as we all know, Cython is kind of a mix of C and Python, so I'm wondering if Cython also borrowed some keywords and RW's from C. Don't get me wrong. This list is very helpful too, but unless the other statement is answered, I can't mark my question as solved. :( – IneptGamer02 Sep 27 '16 at 04:31
  • " cython/docs/sphinxext/cython_highlighting.py - the file for documentation highlighting might be useful. It has lists of keywords and builtins. " Is that really all there is to Cython's? If so, then be assured that I'm sincerely grateful. I need your reply so I could mark your answer as accepted. :) – IneptGamer02 Sep 27 '16 at 04:35
  • Does `cython` try to parse the `c` code? It isn't a `c` compiler; rather it generates `c` code; so it may incorporate code without parsing. Check the docs. – hpaulj Sep 27 '16 at 05:28
  • I see, you have a point. Thank you, I accepted your answer. :) – IneptGamer02 Sep 27 '16 at 05:37