attach cString to memoryview?

Phlip phlip2005 at
Wed Aug 3 15:13:24 CEST 2011


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 check_me

# check_it = call_4('ls')
# check_it()

assert '' 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-


More information about the Python-list mailing list