[Tutor] How to pass varying number of arguments to functions called by a dictionary?

boB Stepp robertvstepp at gmail.com
Wed Feb 11 18:47:26 CET 2015


On Wed, Feb 11, 2015 at 10:58 AM, Dave Angel <davea at davea.name> wrote:
> On 02/11/2015 10:29 AM, boB Stepp wrote:
>>
>> On Wed, Feb 11, 2015 at 8:45 AM, Dave Angel <davea at davea.name> wrote:
>>>
>>> On 02/11/2015 08:27 AM, boB Stepp wrote:

[...]

>>> In each case, there are probably better ways...
>>
>>
>> I am open to suggestions!
>>
>
> So where does the data for these parameters come from?  In other words, who
> is your user?  Why isn't that user just calling the functions directly?  You
> mention you're getting the function code-letters from a data file.  Are you
> getting the data for the parameters from there as well?

The user uses their software application to create a treatment plan
that they want to evaluate versus agreed values for a variety of
parameters. These agreed values will exist in a data file that I
create. It is likely that there will eventually be multiple such data
files as the planner may be asked to compare their plan versus
multiple sets of consensus data, which can come from a variety of
sources. But right now I will have just one data file that our group
has agreed to use. The user calls my program. The only choices he
would get to make are if we move to more than one set of data to
compare plans to. Which functions that get called will depend on the
data file and existing information in the plan the user created. The
passed values to functions will come both from the data file and
previously extracted information from the user's plan.

> If all the data, and the corresponding function codes, are coming from the
> data file, then you must be deserializing that file in some way. And unless
> the data is always strings, there's more work to do there than in the
> wrapping of the calls themselves.

The data is currently entirely in string format. I am currently
constructing the file as a template that will also provide the format
for the final display window. Basically, the program will copy
anything needed for GUI, filling in any information fields that are
plan-dependent, and only include organ structures that the user
contoured in his plan, evaluating dose to these in accordance with the
data table(s) I have been told to include. The data file will not be
large. In the end there will probably be no more than 2 or 3 screens
worth of data.

> There are libraries for serializing and deserializing arbitrary data. Some
> use xml, some use json, axon, csv, YAML, and probably tons of others.
> Likewise there are protocols such as SOAP, for remote procedure calls.

I was told in an earlier question I posted from several months ago
that my proposed file design resembled the json format. I am keeping
that in the back of my mind as I continue to work my way through this
project.

> Is the file entirely linear, or are you going to be doing branching,
> subroutining, etc?  If there's any more complexity, you need to see the
> whole picture before you just do the call.

For a given organ, the consensus data being used will require one or
more checks with the actual plan data. This will vary for each
possible organ. So based on the data format I use, it will signal the
data reader the number and type of checks to do as well as what values
the plan results will be compared to. So there is some complexity
here.

> Do any of these functions have return values?  How are you handling that?

Getting information into and out of the planning software can only be
done indirectly. Because of this the functions will "print" planning
software scripting commands to a temporary file. Once all such
operations are done, this temporary file gets run (a reload script),
which then actually does the work within the planning software. If
information then needs to get from the planning software back to a
Python program, then I have two options: 1) Save from within the
planning software to a temp file that the Python program can access,
or, 2) pass these values via a Unix command to a Python program.



-- 
boB


More information about the Tutor mailing list