How to set the 3D-View clip with an API command?
The hassle is the context.space_data (generally aka context.area.spaces.active) pertains to the console area, which is in context when you are in the console, rather than a 3d view.

Here is some console code, to find a 3D view in the current (context) screen.

&gt;&gt;&gt; C.space_data.type
'CONSOLE'

&gt;&gt;&gt; for a in C.screen.areas:
...     if a.type == 'VIEW_3D':
...         break
...         
&gt;&gt;&gt; a
bpy.data.screens['Scripting']...Area

&gt;&gt;&gt; a.spaces.active.type
'VIEW_3D'

&gt;&gt;&gt; a.spaces.active.clip_end = 500