Contribute to utils.py, a simple method of shortening code writing

Hello BlenderArtists!
Here i am writing a brief post, based around a notion i had today.
Whenever i write code, i notice that i commonly use the same variables and variables names, and i have to go through the process of defining each of these, such as

import bge
cont = bge.logic.getCurrentController()

Now, it is common knowledge that modules can be stored as text files in blender text editor, if you wish to use a custom module.
So, what am i requesting?
Well, i thought that writing a simple “utils.py” which you import using a simple line of code, would import all the common variables used, and define them as short hand
e.g cont.
I have already found this incredibly useful, and so i am requesting that the community suggest snippets of code that they frequently use, so i can add them to the utils.py module!
Please read the code below, so as not to submit predefined code, or use the same variable names.
Also, please suggest better variable keys if they appear illogical!

import bge
cont = bge.logic.getCurrentController()
own = cont.owner

scene = bge.logic.getCurrentScene()
objects = scene.objects

ori = own.orientation
pos = own.position

# Define Sensors
for i in cont.sensors:
    exec(i.name + " = i")
# Define Actuators
for i in cont.actuators:
    exec(i.name + " = i")
    
    

I think:

# Define Sensors
for i in cont.sensors:
    exec(i.name + " = i")
# Define Actuators
for i in cont.actuators:
    exec(i.name + " = i")

Should probably be replaces with

# Define Sensors
for sensor in cont.sensors:
    globals()[sensor.name] = sensor
# Define Actuators
for actuator in cont.actuators:
    globals()[actuator.name] = actuator

Why is that andrew?

globals() gives you a dictionary of the global attributes ( as locals() gives you the local attributes ).
It is saver than exec() and I think a bit faster.

what I use very often is:


#===============================================================================
# onePositive
#===============================================================================
def onePositive(cont):
 for sensor in cont.sensors:
  if sensor.positive:
   return True
 return False

and it’s (not so often used) counterpart


#===============================================================================
# allPositive
#===============================================================================
def allPositive(cont):
 for sensor in cont.sensors:
  if not sensor.positive:
   return False
 return True

Thansk monster. I (of course) am fully aware or global variables, it was more a question of why globals over exec.
If it’s a security concern, then indeed use globals()