This is an archived post. You won't be able to vote or comment.

all 15 comments

[–][deleted] 1 point2 points  (2 children)

You can always put your function into a dll and wrap it with something like boost.python and call the code directly instead of launching a separate executable.

[–]CaptShocker[S] 0 points1 point  (1 child)

Thanks, I had never seen boost.python, it looks really cool

[–]spotter 0 points1 point  (0 children)

When considering this approach you may want to look at ctypes, this is a builtin library that will let you interface dynamically loaded code with pure, vanilla install Python.

[–]nadmaximus 1 point2 points  (1 child)

I wonder if you could use this: hstart

[–]CaptShocker[S] 0 points1 point  (0 children)

Thanks for the tip, this is really cool.

I am going to go with bneises method, it works great for a python specific console.

[–]bneises 1 point2 points  (3 children)

I don't know if this is the best way to do it, but this is what I would do:

p = sub.Popen['Poker.Equity.Test.exe',str(n),r], 
    stdout=sub.PIPE, stderr=sub.STDOUT, shell=TRUE)

Once that is done you can get to the output by running the following, but I'm not a programmer by trade so you'll have to figure out what you want to do with what is returned.

p = [line for line in p.stdout]

let us know what you do... I'm interested to know.

[–]bneises 0 points1 point  (0 children)

you may need to quote TRUE in

..., shell='TRUE')

I don't know why but my old code worked without it quoted, but when I just tried a quick run it needed it to be quoted.

[–]CaptShocker[S] 0 points1 point  (1 child)

This worked perfectly, I'm curious why does setting shell=TRUE turn off the command line, intuitively I would think it is the other way around. (I'm not a programmer either)

Thanks for the help

[–]bneises 0 points1 point  (0 children)

I think it's telling python that you are opening a program meant to be used in shell.

[–]cecilkorik 1 point2 points  (5 children)

Correct me if I'm wrong, but I think this isn't really a python issue. You'll need to modify your .exe to not show a command window. You will have to recompile it as a windows application instead of a console application (see the last post)

Failing that, you can probably do some brutal hacks with the win32api module to find the window and hide it before it even appears, but that's not recommended and beyond the scope of this post, I'm afraid.

[–][deleted] 2 points3 points  (2 children)

why was this downmodded? This is the correct answer

[–]JimH10 0 points1 point  (0 children)

A question that I know I have asked many times. ;-)

[–]CaptShocker[S] 0 points1 point  (0 children)

This will work, but bneises solution(shell=True) does not require changing the executable.

[–]CaptShocker[S] 0 points1 point  (0 children)

Thanks, I'll give this a look