Re: Retrieving Python Keywords

2011-04-11 Thread Glazner
On Apr 10, 4:28 am, candide wrote: > Python is very good at introspection, so I was wondering if Python (2.7) > provides any feature to retrieve the list of its keywords (and, as, > assert, break, ...). >>> import keyword >>> keyword.kwlist ['and', 'as', 'assert', 'break', 'class', 'continue', 'd

Re: Retrieving Python Keywords

2011-04-10 Thread Terry Reedy
On 4/10/2011 5:12 AM, candide wrote: Le 10/04/2011 04:01, Terry Reedy a écrit : Yes. (Look in the manuals, I did : my main reference book is the Martelli's /Python in a Nutshell/ You should only use that as a supplement. and the index doesn't refer to the keyword import and now you kno

Re: Retrieving Python Keywords

2011-04-10 Thread candide
Le 10/04/2011 04:01, Terry Reedy a écrit : Yes. (Look in the manuals, I did : my main reference book is the Martelli's /Python in a Nutshell/ and the index doesn't refer to the keyword import or try the obvious imports ;-) The only obvious I saw was sys module. -- http://mail.python

Re: Retrieving Python Keywords

2011-04-10 Thread candide
Le 10/04/2011 04:09, John Connor a écrit : Actually this is all it takes: import keywords print keywords.kwlist >>> import keywords Traceback (most recent call last): File "", line 1, in ImportError: No module named keywords >>> so I considered first it was a joke ! ;) In fact the import

Re: Retrieving Python Keywords

2011-04-09 Thread Steven D'Aprano
On Sun, 10 Apr 2011 03:28:10 +0200, candide wrote: > Python is very good at introspection, so I was wondering if Python (2.7) > provides any feature to retrieve the list of its keywords (and, as, > assert, break, ...). import keyword -- Steven -- http://mail.python.org/mailman/listinfo/python

Re: Retrieving Python Keywords

2011-04-09 Thread John Connor
Actually this is all it takes: import keywords print keywords.kwlist --jac On Sat, Apr 9, 2011 at 8:57 PM, Chris Angelico wrote: > On Sun, Apr 10, 2011 at 11:28 AM, candide wrote: >> Python is very good at introspection, so I was wondering if Python (2.7) >> provides any feature to retrieve the

Re: Retrieving Python Keywords

2011-04-09 Thread Terry Reedy
On 4/9/2011 9:28 PM, candide wrote: Python is very good at introspection, so I was wondering if Python (2.7) provides any feature to retrieve the list of its keywords (and, as, assert, break, ...). Yes. (Look in the manuals, or try the obvious imports ;-) -- Terry Jan Reedy -- http://mail.pyt

Re: Retrieving Python Keywords

2011-04-09 Thread Chris Angelico
On Sun, Apr 10, 2011 at 11:28 AM, candide wrote: > Python is very good at introspection, so I was wondering if Python (2.7) > provides any feature to retrieve the list of its keywords (and, as, assert, > break, ...). I don't know about any other way, but here's a really REALLY stupid method. For

Retrieving Python Keywords

2011-04-09 Thread candide
Python is very good at introspection, so I was wondering if Python (2.7) provides any feature to retrieve the list of its keywords (and, as, assert, break, ...). -- http://mail.python.org/mailman/listinfo/python-list