Path to current script

Just started looking at some Python coding for Blender, and almost immediately I’ve hit a snag. I can’t find a way to retrieve the location of the currently running script.

From the Python forums it looks like I’m not the first person to have this problem, and there still doesn’t seem to be a good solution to it as far as I can see. And to add to it, running the script from Blender seems to negate what workarounds were available.

Does anyone know a way to determine the path to the currently running Python script when it’s been run from within Blender ?

If not, who do I bug to get such a feature added to the Python API in the next release ? It should be pretty trivial to do.

Why do I need it ? Basically it would mean that you could drag and drop install multiple modules without having to worry about PYTHONPATH because the script could modify it for you.

Setanta