Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #10805 > unrolled thread
| Started by | Phlip <phlip2005@gmail.com> |
|---|---|
| First post | 2011-08-03 06:13 -0700 |
| Last post | 2011-08-03 15:41 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
attach cString to memoryview? Phlip <phlip2005@gmail.com> - 2011-08-03 06:13 -0700
Re: attach cString to memoryview? Peter Otten <__peter__@web.de> - 2011-08-03 15:41 +0200
| From | Phlip <phlip2005@gmail.com> |
|---|---|
| Date | 2011-08-03 06:13 -0700 |
| Subject | attach cString to memoryview? |
| Message-ID | <4232b39e-e07c-4e12-92e3-1e7b035422a6@a2g2000prf.googlegroups.com> |
HypoNt;
My ulterior motive is the perfect command spawner:
def call_4(cmd):
import cStringIO
# memoryview type
# New in version 2.7.
v = memoryview('abcefg')
q = cStringIO.StringIO()
p = Popen(cmd, shell=True, stdout=q, bufsize=4096)
def check_me():
# consider: examine p or v here
return q.read()
return check_me
# check_it = call_4('ls')
# check_it()
assert 'fabfile.py' in call_4('ls')()
# Look, ma! No self.!
The Subject line problem refers to how to get rid of this:
AttributeError: 'cStringIO.StringO' object
has no attribute 'fileno'
To give it one, plug in a memoryview, right?
Pencils down in 15 minutes, okay? Go! While I'm googling up a more
mundane (and less performant) solution with a normal file...
Distractingly yrs-
--
Phlip
http://bit.ly/ZeekLand
[toc] | [next] | [standalone]
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2011-08-03 15:41 +0200 |
| Message-ID | <j1bj73$a33$1@solani.org> |
| In reply to | #10805 |
Phlip wrote: > q = cStringIO.StringIO() > p = Popen(cmd, shell=True, stdout=q, bufsize=4096) > The Subject line problem refers to how to get rid of this: > > AttributeError: 'cStringIO.StringO' object > has no attribute 'fileno' What's wrong with subprocess.PIPE? >>> import subprocess as sp >>> p = sp.Popen(["ls", "/usr/lib/python2.6"], stdout=sp.PIPE) >>> print p.communicate()[0]
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web