Hi there,
I hope this is trivial and I just didn't find it in the tutorials. I am writing python code that 'supervises' c code, aka I run the c code with ctypes from python. Now I want to 'catch' the c 'printfs' to process the data that is output by the c code. Any idea how one would do this?
Thanks
...
Python 2.6.5 is said to support Unicode? How come listdir() doesn't in IDLE, but Python 3.1.2 does show Unicode in IDLE? (this is tested on Windows 7)
The following code is the same behavior:
for dirname, dirnames, filenames in os.walk('c:\path\somewhere'):
for subdirname in dirnames:
print (os.path.join(dirname, subdirna...
Dear All
i have developed a scheme for signcryption, i want to test the time taken for modular exponentiation. i am using the below code for signcryption part
start = time.clock()
gamma = pow(g , x, p)
print ('The value of gamma is : '),gamma
Time_signcrypt = time.clock() - start
and for unsigncryption part i am calculating the t...
Hi all!
I am new to python and scrapy and hence am getting some basic doubts(please spare my ignorance about some fundamentals,which i m willing to learn :D).
Right now I am writing some spiders and implementing them using scrapy-ctl.py from the command line by typing:
C:\Python26\dmoz>python scrapy-ctl.py crawl spider
But I do not w...
On bash or Window's Command Prompt, we can press the up arrow on keyboard to get the last command, and edit it, and press ENTER again to see the result.
But in Python's IDLE 2.6.5 or 3.1.2, it seems if our statement prints out 25 lines, we need to press the up arrow 25 times to that last command, and press ENTER for it to be copied?
Or...
I have given date strings like these:
Mon Jun 28 10:51:07 2010
Fri Jun 18 10:18:43 2010
Wed Dec 15 09:18:43 2010
What is a handy python way to calculate the difference in days? Assuming the time zone is the same.
The strings were returned by linux commands.
Edit: Thank you, so many good answers
...
I'm running a bunch of queries using Python and psycopg2. I create one large temporary table w/ about 2 million rows, then I get 1000 rows at a time from it by using cur.fetchmany(1000) and run more extensive queries involving those rows. The extensive queries are self-sufficient, though - once they are done, I don't need their results a...
Hey all,
While optimizing performance of an app of mine, I ran across a huge performance bottleneck in few lines of (Python) code.
I have N tokens. each token has a value assigned to it. Some of the tokens contradict (e.g. tokens 8 and 12 cannot "live together"). My job is to find the k-best token-groups. The value of a group of token...
I am getting this error:
DataError: (DataError) invalid input syntax for integer: "1.50" CONTEXT: PL/pgSQL function "sp_aggregate_cart" line 82 at FOR over EXECUTE statement 'SELECT total_items, subtotal, is_shipping_required, discount_other, is_shipping_discount FROM sp_aggregate_cart(8135)' {}
When running my application code. When...
Hi I'm siting with my custom storage system 1 day. And now when I'm trying import it it gives me this Error.
I put in file models.py
from FTPStorage import FTPStorage
import datetime
from django.db import models
fs=FTPStorage()
class Upload(models.Model):
"""Uploaded files."""
file = models.FileField(upload_to='uploads', store...
Hi,
I am using the md5 function to hash a string into a 32 digit string.
str_to_encode = 'this is a test string which I want to encode'
encoded = hashlib.md5(str_to_encode).hexdigest()
I want to be able to decode this string (i.e. encoded in the example above) back to its original value. I don't think this is possible using md5 (bu...
so here is my code:
import wx
from ConfigParser import *
class settings(wx.Frame):
def __init__(self,parent,id):
wx.Frame.__init__(self,parent,id,'Frame aka window', size=(500,500))
panel=wx.Panel(self)
configuration = ConfigParser()
configuration.read('SerialReader.conf')
self.ACTIVE_MES...
I have some data that I'd like to save in an excel file. How does one do this in python?
...
How do you debug (trace execution) of a pylons web application?
(using a mac with textmate)
...
I m using python 2.6 version, for small python script while building it i m getting same kind of errors "sh: ldd: command not found"
Below ones are the few errors
copying /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/_bisect.so -> /Users/zoho/Desktop/dist/_bisect.so
sh: ldd: command not found
copy...
Hi, I'd like to a convert unix timestamp I have in a string (ex. 1277722499.82) into a more humanized format (hh:mm:ss or similar). Is there an easy way to do this in python for a django app? This is outside of a template, in the model that I would like to do this. Thanks.
edit
I'm using the python function time.time() to generate the...
The story began with a very strange error while I was running my script from PyDev. Running the same script from outside will not encounter the same problem.
Fatal Python error: Py_Initialize: can't initialize sys standard streams
File "C:\Python26\lib\encodings\__init__.py", line 123
raise CodecRegistryError,\
...
Hi,
I have a Python script which uses the MySQLdb interface to load various CSV files into MySQL tables.
In my code, I use Python's standard CSV library to read the CSV, then I insert each field into the table one at a time, using an INSERT query. I do this rather than using LOAD DATA so that I can convert null values and other minor c...
Question: When does the actual writing to the sqlite3 db file take place and what happens if it is interrupted?
Info:
I have this program in python that I've been working on for a few weeks that uses sqlite3 to store large amounts of data from the simulation it is running. But there are two situations I'm worried about.
We've been ...
I am new to database programming with Google App Engine and am programming in Python. I was wondering if I am allowed to have one Python file with several request handler classes, each of which has get and post methods. I know that the yaml file allows me to specify which scripts are run with specific urls, like the example below:
hand...