attach cString to memoryview?

P

Phlip

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-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top