Python / Shared Lib Q

Hi all,

Is it possible to create a shared library function or python function that can be called at any time from inside a blender menu, or by binding it to a key?