views:

223

answers:

2

I have a web API that returns python dictionaries or lists as a response that I eval() in python scripts that use the API, for completness I wanted to set a proper content-type but not sure what would be best to use "text/x-python" or maybe "application/python", or something else?

[edit] I'm also outputting JSON, I'm doing Python as an option mainly for internal use.[/edit]

+6  A: 

I doubt there's an established MIME type. Have you considered using JSON instead, it is almost the same as a Python dict, and has a better established culture of tools and techniques.

Ned Batchelder
I agree that JSON might well be best. Plus call eval() on some arbitrary string retrieved from a web service seems a little insecure...
John Montgomery
I'm outputting both as an option, I settled on "application/json" for that one. Internally we use alot of python so I wanted to provide something that had required no external modules to use.
RaySl
The json module is included in 2.6. Besides, for the most part you can eval json and get sensible results (though as John mentions, that's not necessarily a great idea).
Aaron Maenpaa
+1  A: 

The authoritative registry is at IANA and, no, there is no standard subtype for Python. So, do not use type like "application/python" but you may use private subtypes such as "text/x-python" (the one I find in the mime-support package on my Debian).

bortzmeyer