Re: trouble controlling vim with subprocess on windows machine
Hi Josiah,
> >> This recipe for asynchronous communication usingsubprocesscould be
> >> used to write an expect-like tool:
> >>http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440554
I have played with the above recipe and it is excellent,
but could you please go into some more detail about what is needed
to make a cross platform [p]expect like (non-pty based) tool?
Specifically, could you describe how you would connect to
*another* interactive Python process with your subclass of
subprocess.Popen?
i.e:
a = Popen('python', stdin=?, stdout=?, stderr=?)
#now run an interactive session with 'a'
I have tried several combinations of the above and I seem
to be stuck on the fact that python is interacting with a
'tty', not 'std*'. Maybe I'm missing a basic piece?
Thanks for any input,
Alex
> >> It works on both Windows and *nix.
>
> >> - Josiah
>
> > I had the original dir work but when I tried to trade it out with vim
> > it isn't clear
> > how I should call it.. vim filename and it doesn't find filename for
> > some reason.
> > I called it pipe and then
>
> > inport pipe
>
> > def load_instrument3(instr_name, csd_name):
> > if sys.platform == 'win32':
> > shell, commands, tail = ('gvim' + csd_name, (csd_name,
> > csd_name), '\r\n')
> > else:
> > shell, commands, tail = ('sh', ('ls', 'echo HELLO WORLD'),
> > '\n')
>
> > a = pipe.Popen(shell, stdin=pipe.PIPE, stdout=pipe.PIPE)
> > print pipe.recv_some(a),
> > for cmd in commands:
> > pipe.send_all(a, csd_name)
> > print pipe.recv_some(a),
> > pipe.send_all(a, csd_name)
> > print pipe.recv_some(a, e=0)
> > a.wait()
>
> The example uses a platform-specific shell in order to use the
> environment variable PATH to discover the executable to run. If you
> know the exact path to your binary ('gvim' for you), it should work.
> As-is, your program would require a binary with the name 'gvim'+csd_name
> in the same path as the script you are executing.
>
> - Josiah
--
http://mail.python.org/mailman/listinfo/python-list
fast method accessing large, simple structured data
Hi, I'm looking for a fast way of accessing some simple (structured) data. The data is like this: Approx 6 - 10 GB simple XML files with the only elements I really care about are the and ones. So what I'm hoping to do is put this data in a format so that I can access it as fast as possible for a given request (http request, Python web server) that specifies just the title, and I return the article content. Is there some good format that is optimized for search for just 1 attribute (title) and then returning the corresponding article? I've thought about putting this data in a SQLite database because from what I know SQLite has very fast reads (no network latency, etc) but not as fast writes, which is fine because I probably wont be doing much writing (I wont ever care about the speed of any writes). So is a database the way to go, or is there some other, more specialized format that would be better? Thanks, Alex -- http://mail.python.org/mailman/listinfo/python-list
Re: fast method accessing large, simple structured data
On Feb 2, 1:50 pm, John Machin <[EMAIL PROTECTED]> wrote: > agc wrote: > > Hi, > > > I'm looking for a fast way of accessing some simple (structured) data. > > > The data is like this: > > Approx 6 - 10 GB simple XML files with the only elements > > I really care about are the and ones. > > > So what I'm hoping to do is put this data in a format so > > that I can access it as fast as possible for a given request > > (http request, Python web server) that specifies just the title, > > and I return the article content. > > > Is there some good format that is optimized for search for > > just 1 attribute (title) and then returning the corresponding article? > > > I've thought about putting this data in a SQLite database because > > from what I know SQLite has very fast reads (no network latency, etc) > > but not as fast writes, which is fine because I probably wont be doing > > much writing (I wont ever care about the speed of any writes). > > > So is a database the way to go, or is there some other, > > more specialized format that would be better? > > "Database" without any further qualification indicates exact matching, > which doesn't seem to be very practical in the context of titles of > articles. There is an enormous body of literature on inexact/fuzzy > matching, and lots of deployed applications -- it's not a Python-related > question, really. Yes, you are right that in some sense this question is not truly Python related, but I am looking to solve this problem in a way that plays as nicely as possible with Python: I guess an important feature of what I'm looking for is some kind of mapping from *exact* title to corresponding article, i.e. if my data set wasn't so large, I would just keep all my data in a in-memory Python dictionary, which would be very fast. But I have about 2 million article titles mapping to approx. 6-10 GB of article bodies, so I think this would be just to big for a simple Python dictionary. Does anyone have any advice on the feasibility of using just an in memory dictionary? The dataset just seems to big, but maybe there is a related method? Thanks, Alex -- http://mail.python.org/mailman/listinfo/python-list
