[Pythonmac-SIG] Spotlight Importing without .py

Nicholas Riley njriley at uiuc.edu
Sun Jan 22 07:40:41 CET 2006

On Sun, Jan 22, 2006 at 12:13:07AM -0500, Nicholas Matsakis wrote:
> So, is it possible there is _no_ standard type code for python source?  If 
> not, any thoughts on registering one?

Indeed, they're text files.  I wouldn't want them to behave any other

The basic problem is that a four-character HFS type code is
insufficient to describe the role of a piece of (potentially
executable) source code.  UTIs map as of 10.4 to a file extension,
MIME type, pasteboard flavor, or OSType (four-character code).

What is lacking is the ability to assign a UTI directly to a file in
place of the HFS type code, and/or to "sniff" a document to determine
its UTI, for example by looking at the shebang line.  The latter was
possible in OS 9 with the Translation Manager, whereby the installed
translation extensions could in turn examine a document to determine
if they could open it.  This facility was dropped in OS X for whatever
reason and has never been restored, but it's a good bet that a future
version of Spotlight will gain something similar though UTI-based.

So, really, all we can do as of 10.4, short of patching frameworks, is
to file bug reports and wait.  Naming your executable Python scripts
something ending in .py or .pyw works too. :-)

Nicholas Riley <njriley at uiuc.edu> | <http://www.uiuc.edu/ph/www/njriley>

More information about the Pythonmac-SIG mailing list