buffer « string « Python Data Type Q&A

Home
Python Data Type Q&A
1.array
2.date
3.dictionary
4.Format
5.integer
6.List
7.numpy
8.regex
9.string
10.tuple
Python Data Type Q&A » string » buffer 

1. Using python ctypes to get buffer of floats from shared library into python string    stackoverflow.com

I'm trying to use python ctypes to use these two C functions from a shared library:

bool decompress_rgb(unsigned char *data, long dataLen, int scale)
float* getRgbBuffer()
The first function is working fine. I can ...

2. A Python buffer that you can truncate from the left?    stackoverflow.com

Right now, I am buffering bytes using strings, StringIO, or cStringIO. But, I often need to remove bytes from the left side of the buffer. A naive approach would rebuild the ...

3. Can I redirect the stdout in python into some sort of string buffer?    stackoverflow.com

I'm using python's ftplib to write a small FTP client, but some of the functions in the package don't return string output, but print to stdout. I want to redirect stdout ...

4. How to iterate over a string using a buffer (python)    stackoverflow.com

I'm trying to find some code that, given a string, will allow me to iterate over each line using the for loop construct, but with the added requirement that separate for ...

5. How do I convert a string to a buffer in Python 3.1?    stackoverflow.com

I am attempting to pipe something to a subprocess using the following line:

p.communicate("insert into egg values ('egg');");

TypeError: must be bytes or buffer, not str
How can I convert the string to a ...

6. TypeError: coercing to Unicode: need string or buffer, User found    stackoverflow.com

i have to crawl last.fm for users (university exercise). I'm new to python and get following error:

 Traceback (most recent call last):
  File "crawler.py", line 23, in <module>
   ...

7. Is it possible to put strings in the copy buffer?    stackoverflow.com

Preferentially using the standard libraries.

8. Python ctypes.create_string_buffer Problem    stackoverflow.com

The ReadProcessMemory function of kernel32.dll appears to be returning Unicode.

kernel32 = ctypes.windll.kernel32
PROCESS_QUERY_INFORMATION = 0x0400
PROCESS_VM_READ = 0x0010

pid = int(raw_input("Enter PID: "))
hproc = kernel32.OpenProcess(PROCESS_QUERY_INFORMATION |PROCESS_VM_READ, False, pid)
lpbaseaddr = 16799644
read_buff = ctypes.create_string_buffer(4)
bytread = ctypes.c_ulong(0)
kernel32.ReadProcessMemory(hproc, ...

9. What is proper Tokenization algorithm? & Error: TypeError: coercing to Unicode: need string or buffer, list found    stackoverflow.com

I'm doing an Information Retrieval Task. As part of pre-processing I want to doing.

  1. Stopword removal
  2. Tokenization
  3. Stemming (Porter Stemmer)
Initially, I skipped tokenization. As a result I got terms like this:
broker
broker'
broker,
broker.
broker/deal
broker/dealer'
broker/dealer,
broker/dealer.
broker/dealer;
broker/dealers),
broker/dealers,
broker/dealers.
brokerag
brokerage,
broker-deal
broker-dealer,
broker-dealers,
broker-dealers.
brokered.
brokers,
brokers.
So, Now I ...

10. How do I build a python string from a raw (binary) ctype buffer?    stackoverflow.com

I'm playing with Python and ctypes and I can't figure out how to resolve this problem. I call to a C function which fills a raw binary data. My code looks ...

11. TypeError: 'str' does not support the buffer interface    stackoverflow.com

string = input("Please enter the text you want to compress")
    file = input("Please enter the desired filename")
    with gzip.open(file+".gz","wb") as f_out:
     ...

12. Python: How to pack different types of data into a string buffer using struct.pack_into    stackoverflow.com

I'm trying to pack some unsigned int data into a string buffer created using ctypes.create_string_buffer. Here is the following code segment, and a running example showing the error on codepad:

import ...

13. TypeError: coercing to Unicode: need string or buffer    stackoverflow.com

This code returns the following error message:

  • with open (infile, mode='r', buffering=-1) as in_f, open (outfile, mode='w', buffering=-1) as out_f: TypeError: coercing to Unicode: need string or buffer, file found
    # Opens ...

14. expected buffer object error on string.translate - python 2.6    stackoverflow.com

I´d appreciate some help for a python novice, I´m trying to delete some characters from a string, like this, for example:

string1 = "100.000"
deleteList = [",", "."]
string1.translate(None, deleteList)

 print string1
but I get ...

15. create_string_buffer throwing error TypeError: str/bytes expected instead of str instance    stackoverflow.com

I am trying this simple ctypes example and getting the error mentioned

>>> from ctypes import create_string_buffer
>>> str = create_string_buffer("hello")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python32\lib\ctypes\__init__.py", line 59, ...

16. Casting string to bytes while parsing XML to Objects ('str' does not support the buffer interface)    stackoverflow.com

I encountered a problem while using function parseString

xml.sax.parseString(src, builder)
TypeError: 'str' does not support the buffer interface I trying change this calling to:
xml.sax.parseString(bytes(src,'utf-8'), builder)
but still not working Python 3.2

17. emacs python mode, python-send-buffer/string/region gives "Invalid Syntax" error    stackoverflow.com

I have used python-mode's python-send-buffer(and similar ones) successfully in a different system in the past. I don't get why I'm getting error here. And worse, googling doesn't help..
Below is the output when ...

18. Longest common prefix using buffer?    stackoverflow.com

If I have an input string and an array:

s = "to_be_or_not_to_be" 
pos = [15, 2, 8]
I am trying to find the longest common prefix between the consecutive elements of the array ...

19. Expected String Or Buffer Error    dreamincode.net

20. "TypeError: expected string or buffer" when reading from csv    python-forum.org

Thank you. I did try passing the list elements the way you suggested but got the same results. Below is the traceback. I've also attached the whois.py. Traceback (most recent call last): File "domainsa.py", line 8, in pywhois.whois(*row) File "/Library/Python/2.6/site-packages/pywhois-0.1dev_r0-py2.6.egg/pywhois/__init__.py", line 12, in whois text = nic_client.whois_lookup(None, domain, 0) File "/Library/Python/2.6/site-packages/pywhois-0.1dev_r0-py2.6.egg/pywhois/whois.py", line 161, in whois_lookup return result UnboundLocalError: local variable ...

21. coercing to unicode: need string or buffer    python-forum.org

from string import ascii_lowercase as f,digits as g;from itertools import product as o,chain as k;s,t=setattr,getattr for k,v in{file:{"writelines":"w"},str:{"splitlines":"n","join":"j","lower":"l","startswith":"s"}}.items(): for m,w in v.items():globals()[w]=t(k,m) u=raw_input;a,b,c=n("""what do you want the filenamne to be sir do you want to include numbers in your wordlist? how many characters do you want your wordlist to be?""");d=l(u(b));v,q,r=open,range,int;e=f+(g if d in ("y","ok")or s(d,"ye")else"") w(v(u(a)+".txt","w"),(j("",h)+"\n"for h in k(*(o(e,repeat=i)for i in ...

23. Convert self.textview.get_buffer() to string?    python-forum.org

I'm coding up my first GTK program, I've already created a console jumbler program and I'm not adding a GTK frontend to it, I'm using TextView to instert the text but my jumbler function doesn't handle it, the output is: , not a jumbled text.. I suspect what the jumbler function is reciving is not ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.