Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Open a file stream to an interactive Python session
- set pystream [open "|/usr/bin/python -i wombat.py" r+]
- fconfigure $pystream -blocking 0
- # Ask Python to calculate Pi
- puts $pystream "w = pi_computing_device(1000)"
- puts $pystream "print w.compute_pi()"
- flush $pystream
- # Spin until we get a response from Python
- # Probably better to use "filevent"
- while {1} {
- set L [gets $pystream foo]
- # Print it to the screen in Tcl
- if {$foo != ""} {
- puts "Pi is approximately equal to $foo"
- break
- }
- }
- # Close the stream to shut down Python
- close $pystream
Add Comment
Please, Sign In to add comment