Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a .NET project at work that provides a couple of (Iron)Python scripts to the customers, to allow them to customize the output of the program. The application generates code for certain machines, and supports a couple of different formats.

Until recently, we only provided a script for one format. We're expanding upon that to include support for the others. If the user is using a script, they select their input script before generating the output code. A script designed for Format1 output is going to cause errors if they're trying to generate Format2 output. I need to deal with this.

One option would just be to let the customers use common sense, and if they load the wrong script it will just fail, or worse, produce inaccurate data. I'm inclined to provide a little more protection than that.

At the moment I'm considering putting a shebang-style comment line at the top of the script, ala:

# OUTPUT - Format1

If the user tries to run a Format2 process with a Format1 script, it will warn them. Alternatively I could create different file extensions for the input scripts that vary by type.

The file-type comment approach helps prevent the script from actually loading improperly, at the cost of failing to warn the user until they've already selected it, via a dialog box. Using different file extensions would allow me to cut down on visual clutter when providing a File Dialog, but doesn't actually stop them from loading the wrong script.

So I'm really not sure if the right approach is to just leave it alone, or provide some safeguards.

share|improve this question

migrated from Jun 2 '12 at 10:15

This question came from our site for user experience researchers and experts.

up vote 0 down vote accepted

Well, no one is answering, so I suppose I'll say what we ended up doing. We ended up putting a programmatic check in the script that ensures the process passed has the correct identifying attribute (in this case, an Enum, which IronPython can compare as a string). If a process with the wrong identifying Enum is passed the script will warn the user and terminate.

Nothing prevents the user from deleting that check from their own script. The same could be said for changing the file extensions or writing a shebang-type line. Nevertheless, it does seem to get the job done without putting in too much effort.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.