Testing if a global is defined in a module

Grant Edwards invalid at invalid.invalid
Tue Jul 5 17:43:02 CEST 2011


On 2011-07-05, Tim Johnson <tim at johnsons-web.com> wrote:
> * Ian Kelly <ian.g.kelly at gmail.com> [110704 20:37]:
>> 
>> It sounds like what you really want is to detect the names *exported*
>> by the module, then.  i
>   Yes! 
>> Why not do it the same way Python does it?  If
>> the module defines an "__all__" attribute, then it is taken to be a
>> sequence of strings which are the exported names.  Otherwise, the
>> exported names are taken to be all the names in the module dict that
>> don't begin with an underscore.
>
>  :) Oh here we go again. Another python feature I didn't know about
>   or have forgotten.

You could probably implement at least two more languages using nothing
but Python features I don't know about or have forgotten.  :)

Yet I still manage to get a lot accomplished using Python.

-- 
Grant Edwards               grant.b.edwards        Yow! I don't know WHY I
                                  at               said that ... I think it
                              gmail.com            came from the FILLINGS in
                                                   my rear molars ...



More information about the Python-list mailing list