Communicating with a program using subprocess

2010-06-17 Thread Laurent Verweijen
I have a file called increment.py as follows: #!/usr/bin/python n = 0 while True: n = int(raw_input(n)) + 1 This is easy to understand, but I want to pipe it's input/output by another python program. (I will show what I

Running a program from another program.

2010-06-17 Thread Laurent Verweijen
I have a program called increment.py as follows: #!/usr/bin/python n = 0 while True: n = int(raw_input(n)) + 1 This is probably very easy to understand, but I want to run this program from another python program. Below is an attempt

Re: how to get bit info

2010-06-17 Thread Laurent Verweijen
Op donderdag 17-06-2010 om 12:51 uur [tijdzone -0700], schreef Back9: > Hi, > > I have one byte data and want to know each bit info, > I mean how I can know each bit is set or not? > > TIA def bitset(x, n): """Return whether nth bit of x was set""" return bool(x & (1 << n)) -- http://mail.pyt

Re: Running a program from another program.

2010-06-17 Thread Laurent Verweijen
Op donderdag 17-06-2010 om 13:01 uur [tijdzone -0700], schreef Stephen Hansen: > On 6/17/10 12:13 PM, Laurent Verweijen wrote: > > How do I make sure the inputstream stays open after the first call to > > communicate? > > This was just asked a few days ago in different

Re: Running a program from another program.

2010-06-17 Thread Laurent Verweijen
Op donderdag 17-06-2010 om 13:48 uur [tijdzone -0700], schreef Stephen Hansen: > On 6/17/10 1:42 PM, Laurent Verweijen wrote: > > I tried putting what Ian Kelly said in my code, by it doesn't work for > > me. > > > > Python 2.6.5 (r265:79063, Apr 16 2010, 13:5

Re: Running a program from another program.

2010-06-17 Thread Laurent Verweijen
Op donderdag 17-06-2010 om 23:09 uur [tijdzone +0200], schreef Laurent Verweijen: > Op donderdag 17-06-2010 om 13:48 uur [tijdzone -0700], schreef Stephen > Hansen: > > On 6/17/10 1:42 PM, Laurent Verweijen wrote: > > > I tried putting what Ian Kelly said in my code, b

Re: Running a program from another program.

2010-06-17 Thread Laurent Verweijen
Op donderdag 17-06-2010 om 14:36 uur [tijdzone -0700], schreef Stephen Hansen: > On 6/17/10 2:09 PM, Laurent Verweijen wrote: > > It just gives me an empty string. > > > > Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) > > [GCC 4.4.3] on linux2 > > Type

Re: Running a program from another program.

2010-06-17 Thread Laurent Verweijen
Op donderdag 17-06-2010 om 14:48 uur [tijdzone -0700], schreef Stephen Hansen: > On 6/17/10 2:40 PM, Laurent Verweijen wrote: > > Op donderdag 17-06-2010 om 14:36 uur [tijdzone -0700], schreef Stephen > > Hansen: > >> On 6/17/10 2:09 PM, Laurent Verweijen wrote: > &g

Re: Running a program from another program.

2010-06-18 Thread Laurent Verweijen
Op donderdag 17-06-2010 om 15:16 uur [tijdzone -0700], schreef Stephen Hansen: > On 6/17/10 3:06 PM, Laurent Verweijen wrote: > >> > >> In your other thread you include an actual traceback: > >> > >> Traceback (most recent call last): > &

Re: I strongly dislike Python 3

2010-06-26 Thread Laurent Verweijen
Since I was relatively new to python when python 3 was released (I'm using it since python 2.5) I don't really care about the print statement. Making print a function makes print less an exception since all other functions need brackets. I also like most of the other changes in python 3 like float

Scan until random delimiter.

2010-06-27 Thread Laurent Verweijen
In contrast to java or c python seems not be able to use a random delimiter. In java, you can do: Code: import java.util.Scanner Scanner sc = new Scanner(System.in).useSeperator(" ") int a = sc.nextInt() But in python there seems to be no other option then waiting until you see a newline. I