[melbourne-pug] Python, VB math simple problem
Ryan Kelly
ryan at rfk.id.au
Sun Apr 2 08:48:00 CEST 2006
> Ideally, I'd love to be able to simply have some extremely small
> executable that just accepts inputs
> does the calculations above and then spits out the outputs. If it were
> possible to write some
> simple lines of math code in Python and then compile these scripts in
> Python to a Windows
> compatible executable,that would be fantastic.
This is certainly possible, but the executable will definitely not be
small. For such a streamlined task, I don't think it would be worth
trying to generate a separate executable.
Instead, why not have your VB program generate a python script that
performs the calculations? Then you can just call the python
interpreter to execute that program. Like so: (dont know VB syntax
sorry)
fp = open_file("do_my_calculations.py")
write(fp,"<<python code that does calculations>>")
write(fp,"<<python code that prints result to 'my_results.txt'>>")
close_file(fp)
execute("C:/Wherever/python.exe do_my_calculations.py")
fp = open_file("my_results.txt")
results = read(fp)
I hope that makes sense - have your VB program generate the python
program on-the-fly, then just run it through the interpreter.
> If it doesn't, how could I get VB to directly pass commands to the
> Python command line and then automatically
> extract the outputs? Shelling out from VB to Python would be tough to
> the command line I think, since the Python command line uses the
> 'Edit / Mark, Paste' approach to inserting, copy inputs, outputs and
> this would be virtually untenable, as far as I can tell to automate
> in a VB shell out routine.
This is basically what I'm advocating, but write the program into a file
rather than try to interact directly with the python interpreter.
Hope that helps,
Ryan
--
Ryan Kelly
http://www.rfk.id.au | This message is digitally signed. Please visit
ryan at rfk.id.au | http://www.rfk.id.au/ramblings/gpg/ for details
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/melbourne-pug/attachments/20060402/4a25ae9f/attachment.pgp
More information about the melbourne-pug
mailing list