name 'bpy' is undefined In test.py I have the following line. It was taken from this page:

bpy.data.objects


Then I start blender from the bash prompt:

blender Rigged\ Hand.blend  --python test.py


The response on the terminal:

Traceback (most recent call last):
  File "/home/sam/proj/Rigged Hand/a/setup.py", line 1, in &lt;module&gt;
    bpy.data.objects
NameError: name 'bpy' is not defined


Even though blender has opened my file, I can open the python prompt inside blender and type the same thing; I get the response &lt;bpy_collection[5], BlendDataObjects&gt; as expected. 

Why can I not use bpy in the script which I invoked from the command line?
"import bpy" first.  

They automatically import that module in the console as a convenience,
so you don't have to type it in every time.  -cheers