Importdoesn'twork
Do you mean the import command? make sure you do it in all lowercase.
Now, in Blender 4.02, this seems to work in the console:
m = D.texts['rename.py'].as_module()m.rename_selected('New Name')