I just checked, and this in a stack script works perfectly:

function pythonFile p
   put the filename of this stack into fp
   set the itemdel to "/"
   put the long seconds into fn
   replace "." with "_" in fn
   put "_temp.py" after fn
   put fn into item -1 of fp
   put p into url ("file:" & fp)
   return shell(quote & "<path to python>" & quote && quote & fp & quote)
end pythonFile

In the real world you'd probably want to set up a single external file (or
set of files? if performance is important and the files need to be used
repeatedly?) and check to make sure you're not accidentally overwriting
something.

On Thu, Jul 20, 2023 at 4:07 PM Bob Sneidar via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Interesting. Ostensibly you could use low level file commands to create
> they python file? Or does the Python script need to be processed by Python
> first?
>
> Bob S
>
>
> > On Jul 20, 2023, at 12:33 PM, Geoff Canyon via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> >
> > I've now figured out that calling a Python file from within LC is as easy
> > as:
> >
> > put shell(quote & "<path_to_python>" & quote && quote &
> > "<path_to_python_file>" & quote)
> >
> > Then whatever gets print()'ed in Python gets returned to LC. Has anyone
> > done work this way and has ideas on best practices for some sort of
> >
> > 1. generate python code
> > 2. write python code to a file
> > 3. write data to a (separate?) file
> > 4. call the code
> > 5. process the results
> >
> > ...loop?
> >
> > gc
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to