python functions

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

python functions

drfg2008
Hi all,

I have a library of the python functions and would like to use it in my SPSS program. What would be the best way to do it:

1. to import my 'myLibrary' as a library of functions and add the path to sys.path;
2. or to have 'myLibrary.py' as a standalone script with main() and run it from a SPSS (something like subprocess.Popen... - excuse my 'pythonian' expression)

I need a little help here, how to accomplish either 1. and/or 2. please?

Thanks,
Dr. Frank Gaeth

Reply | Threaded
Open this post in threaded view
|

Re: python functions

Jon K Peck
#1 is easy and works well.  You can set up a sitecustomize.py file to automatically include a list of locations calling sys.path.append to add them.  However, the extensions subdirectory of your Statistics installation and some others are automatically added to the path when you are running Statistics.

If you don't need the gui, e.g., for production jobs, consider external mode, where you run a top-level Python program that runs your Python and SPSS code.  No need for a subprocess.  This can be faster, since it doesn't need to handle the GUI.  If you have mostly regular syntax with some Python extras, though, #1 would probably make more sense.

Finally, if you have some specialized programs you need to run, consider making them into extension commands and just using them as regular syntax.




Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
phone: 720-342-5621




From:        drfg2008 <[hidden email]>
To:        [hidden email],
Date:        08/27/2013 11:39 AM
Subject:        [SPSSX-L] python functions
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Hi all,

I have a library of the python functions and would like to use it in my SPSS
program. What would be the best way to do it:

1. to import my 'myLibrary' as a library of functions and add the path to
sys.path;
2. or to have 'myLibrary.py' as a standalone script with main() and run it
from a SPSS (something like subprocess.Popen... - excuse my 'pythonian'
expression)

I need a little help here, how to accomplish either 1. and/or 2. please?

Thanks,




-----
Dr. Frank Gaeth
FU-Berlin

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/python-functions-tp5721756.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD