question about python statements

Ohad Frand ohad.frand at percello.com
Tue May 13 04:16:51 EDT 2008


Hi
Thanks a lot for your reply
I think the main uses for it is to study the language and to see that I
didn't miss anything else or that something is changed from one version
to another.

The keyword module will help me

Thanks again
Ohad Frand


-----Original Message-----
From: Gary Herron [mailto:gherron at islandtraining.com] 
Sent: Tuesday, May 13, 2008 11:11 AM
To: Ohad Frand
Cc: python-list at python.org
Subject: Re: question about python statements

Ohad Frand wrote:
> Hi Gary
>
> Sorry that I was not clear, I hope that this time I will explain
myself
> better.
>
> I can get list of all builtin functions in python by
dir(__builtins__).
> This return a list of string with most known names to python language
> such as: 
> [... 'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'long',
> 'map', 'max', 'min', 'object', 'oct', 'open', 'ord', 'pow',
'property',
> 'quit', 'range', 'raw_input', 'reduce', 'reload'...]
>
> But I don't know how to generate the next list of builtin python
> statements:
>
['assert','break','class','continue','def','del','elif','else','except',
> 'exec','finally','for','from','global',
> 'if','import','pass','print','raise','return','try','while','yield']
>   

There is no way you can consider 'elif', 'else', 'except', and 'from' 
statements.  However, as someone pointed out, the kwlist from the 
keyword module is the closest thing we can think of to the list you are 
asking for.

On the other hand, what's wrong with constructing the list as you did in

your example above?


Just out of curiosity, *why* do you want this list.   Perhaps is we knew

that, we could think of a programmatic way to construct the list you 
want.   The biggest challenge at the moment is that we have no idea what

you mean by statement, but it is certainly not what Python considers 
statements.

Gary Herron



> Thanks,
> Ohad Frand
>
> -----Original Message-----
> From: Gary Herron [mailto:gherron at islandtraining.com] 
> Sent: Monday, May 12, 2008 10:41 PM
> To: Ohad Frand
> Cc: python-list at python.org
> Subject: Re: question about python statements
>
> Ohad Frand wrote:
>   
>> Hi
>>
>> I am looking for a way to programmically get a list of all python 
>> existing statements that I cannot access by __builtins__ or locals()
>>
>> (like ["assert","break","class",...])
>>
>> Thanks,
>>
>> Ohad
>>
>>
>>     
>
------------------------------------------------------------------------
>   
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>     
> Sorry, I've no idea what you mean here. Perhaps you could help us by 
> defining what you mean by
> "statements that I cannot access by __builtins__ or locals()"
>
> Is there any statement that you *can* access in such a way?
>
> What does it even mean to "access a statement"?
>
> Do you even have a list of "statements" from which we are to work? 
> Python is a little unusual in what it considers statements.
>
> Gary Herron
>
>
>
>
>   




More information about the Python-list mailing list