List Info

Thread: Python, VB math simple problem




Python, VB math simple problem
user name
2006-04-02 06:48:00
> 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
ryanrfk.id.au        |  http://www.rfk.id
.au/ramblings/gpg/ for details

_______________________________________________
melbourne-pug mailing list
melbourne-pugpython.org
http://mail.python.org/mailman/listinfo/melbourne-pug
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )