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 ... |
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 ... |
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 ... |
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 ... |
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 ... |
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>
...
|
Preferentially using the standard libraries.
|
|
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, ...
|
I'm doing an Information Retrieval Task. As part of pre-processing I want to doing.
- Stopword removal
- Tokenization
- 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 ... |
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 ... |
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:
...
|
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 ...
|
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 ...
|
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 ... |
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, ...
|
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
|
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 ... |
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 ... |
|
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 ... |
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 ... |
|
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 ... |