Re: How to get inputs for a python program that run from another python program

2007-06-12 Thread pyscottishguy
On Jun 11, 7:47 am, pradeep nair <[EMAIL PROTECTED]> wrote: > I would like to know how to pass keyboard input for a python script > which is ran by another script. > > for eg: > > hello1.py: > > import os > > if __name__=='__main__': > > print "I will call this other program called hello.py" >

pyparser and recursion problem

2007-07-26 Thread pyscottishguy
Hi, Using pyparser, I'm trying to parse a string like this: :Start: first SECOND THIRD :SECOND: second1 | second2 :THIRD: third1 | FOURTH :FOURTH: fourth1 | fourth2 I want the parser to do the following: 1) Get the text for the :Start: label e.g ('first SECOND THIRD') 2) Do nothing with the l

Re: pyparser and recursion problem

2007-07-26 Thread pyscottishguy
Hey, Thanks Neil and Paul! After reading Neil's advice I started playing around with the setParseAction method, and then I found Paul's script 'macroExpander.py' (http://pyparsing.wikispaces.com/space/showimage/ macroExpander.py). With only a few modifications to macroExpander.py (and reversing

Re: pyparser and recursion problem

2007-07-27 Thread pyscottishguy
Hey, Thanks for the further explanations. I'm going to play around more with the 'recursive grammar' and 'parse-time dynamic grammar element' stuff so that I understand it a bit better. I liked the changes you suggested. The alternative grammar definitely makes the code easier to understand, plu

Re: Efficient Rank Ordering of Nested Lists

2007-08-03 Thread pyscottishguy
On Aug 2, 10:20 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > A naive approach to rank ordering (handling ties as well) of nested > lists may be accomplished via: > >def rankLists(nestedList): > def rankList(singleList): > sortedList = list(singleList) > sortedL

'Advanced' list comprehension? query

2007-08-08 Thread pyscottishguy
Hi, I'm playing around with list comprehension, and I'm trying to find the most aesthetic way to do the following: I have two lists: noShowList = ['one', 'two', 'three'] myList = ['item one', 'item four', 'three item'] I want to show all the items from 'myList' that do not contain any of the s

Re: Colored text

2007-08-13 Thread pyscottishguy
On Aug 13, 10:37 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-08-13, Michael Bentley <[EMAIL PROTECTED]> wrote: > > > > > On Aug 12, 2007, at 7:05 PM, Rohan wrote: > >> Can some one tell me how do I get colored text. Say when I want to > >> write something in a text file , how do I get it

creating and appending to a dictionary of a list of lists

2007-08-14 Thread pyscottishguy
Hey, I started with this: factByClass = {} def update(key, x0, x1, x2, x3): x = factByClass.setdefault(key, [ [], [], [], [] ]) x[0].append(x0) x[1].append(x1) x[2].append(x2) x[3].append(x3) update('one', 1, 2, 3, 4) update('one', 5, 6, 7, 8) update('two', 9, 10, 11, 12) p

Re: creating and appending to a dictionary of a list of lists

2007-08-15 Thread pyscottishguy
On Aug 15, 8:08 am, Ant <[EMAIL PROTECTED]> wrote: > On Aug 15, 3:30 am, [EMAIL PROTECTED] wrote: > > > Hey, > > > I started with this: > > > factByClass = {} > > ... > > def update(key, *args): > > x = factByClass.setdefault(key, [[], [], [], [] ]) > > for i, v in enumerate(args): > >

Re: 'REPL' style IDE

2007-08-21 Thread pyscottishguy
How about embedding ipython in your script with: from IPython.Shell import IPShellEmbed ipshell = IPShellEmbed() ** your set up code ** ipshell() # this call anywhere in your program will start IPython see: http://ipython.scipy.org/doc/manual/node9.html#sec:embed Here are some ipython tips: h