First off name is not a namespace - its a reference to the name of the module it belongs to, ie: somemod. Py somemod. __name__ == 'somemod The exception to this being if you run a module as an executable from the commandline, then the name is '__main in your example there is a lucky coincidence that your module being run as main is also named main Execfile executes the contents of the module WITHOUT importing it as a module.As such, the name doesn't get set, because its not a module - its just an executed sequence of code.
First off, __name__ is not a namespace - its a reference to the name of the module it belongs to, ie: somemod. Py -> somemod. __name__ == 'somemod' The exception to this being if you run a module as an executable from the commandline, then the __name__ is '__main__'.
In your example there is a lucky coincidence that your module being run as main is also named main. Execfile executes the contents of the module WITHOUT importing it as a module. As such, the __name__ doesn't get set, because its not a module - its just an executed sequence of code.
This hasn't really answered my question. – Moe Apr 3 '09 at 13:39 The answer provided by David Locke covers this - its covered in the python documentation. – Max Apr 3 '09 at 19:10 No it doesn't, his answer says that builtins is added to the dictionary passed in for locals (unless I am misinterpreting).
– Moe Apr 3 '09 at 20:55.
The execfile function is similar to the exec statement. If you look at the documentation for exec you'll see the following paragraph that explains the behavior. As a side effect, an implementation may insert additional keys into the dictionaries given besides those corresponding to variable names set by the executed code.
For example, the current implementation may add a reference to the dictionary of the built-in module __builtin__ under the key __builtins__ (!). Edit: I now see that my answer applies to one possible interpretation of the question title. My answer does not apply to the actual question asked.
As an aside, I prefer using __import__() over execfile: module = __import__(module_name) value = module. __dict__function_name(arguments) This also works well when adding to the PYTHONPATH, so that modules in other directories can be imported: sys.path. Insert(position, directory).
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.