How do you stretch an object from multiple vertices using a python script? This object here is supposed to a be a model of a p orbital in chemistry. I wish to cause it to elongate and widen at one end and narrow down at the other. Is there any way to do it that doesn't involve altering every vertex to get the required shape. This task will be handled by a script.

One method I thought of is a way of linking adjacent vertices for relative movement. Being a beginner at Blender, I have no clue if this is supported or not.

Thanks

Edit1 : Reason for requirement: This orbital is intended to stretch and deform like an electron cloud under the influence of an electric field. I was trying to model this behaviour using the script. For example, after each alternate frame, stretch the orbital 'x' amount to model an increasing electric field.

Any suggestions of a different approach to this is more than welcome.
It'll be something like this, assuming Icosphere at origin.
Note: you have to start in Edit mode for some reason, otherwise it throws an error.

import bpy
import bmesh

obj  = bpy.data.objects['Icosphere'] ## set name
mesh  = bpy.data.meshes['Icosphere']

bpy.ops.object.mode_set(mode = 'EDIT')
bm  = bmesh.from_edit_mesh( mesh )

minX  = 0
corners  = obj.bound_box
trans  = bpy.ops.transform

for corner in range(len(corners)):
  x = corners[corner][0]
  if x &lt; minX:
    minX  = x

for v in range(len(bm.verts)):
  vert = bm.verts[v]
  if vert.co.x == minX:
    vert.select_set(1)
  else:
    vert.select_set(0)

trans.translate( value = (-5, 0, 0), 
                 constraint_axis = (False, False, False), 
                 constraint_orientation = 'GLOBAL', 
                 mirror = False, 
                 proportional = 'ENABLED', 
                 proportional_edit_falloff = 'SMOOTH', 
                 proportional_size = 2 )

trans.resize(value = (0.3, 0.3, 0.3), 
             constraint_axis = (False, False, False), 
             constraint_orientation = 'GLOBAL', 
             mirror = False, 
             proportional = 'ENABLED', 
             proportional_edit_falloff = 'SMOOTH', 
             proportional_size = 2 )