I gave up to make "sqlite3" working but I just found out (with help("modules")) that I have "sqlite" module. I tested it (create table, insert some values and so on) and it works fine. But before I start to use this module I would like to know if it has some significant limitations in comparison with sqlite3 module? Can anybody, pleas, g...
After thinking quite a while about how to make a fast and scalable web application, I am almost decided to go for a combination of Google App Engine, Python+Django, and app-engine-patch. But I came across a comment in the app-engine-patch FAQ that made me think that perhaps the combination is not quite as mature as I thought: it may take...
I was wondering if there is a way to convert my QT (version 4.50) menu and all its submenus into a text document in something similar to the following format:
Menu 1
Sub Menu 2
Menu 2
sub menu 3
sub menu 4
sub menu 1
...
Hi, I have the following simple code:
import urllib2
import sys
sys.path.append('../BeautifulSoup/BeautifulSoup-3.1.0.1')
from BeautifulSoup import *
page='http://en.wikipedia.org/wiki/Main_Page'
c=urllib2.urlopen(page)
This code generates the following error messages:
c=urllib2.urlopen(page)
File "/usr/lib64/python2.4/urllib2....
I want to hack around with the Python interpreter and try creating a small DSL . Is there any module where I can do something like this theoretical code (similar to LINQ expression trees)?
expression_tree = Function(
Print(
String('Hello world!')
)
)
compile_to_bytecode(expression_tree)
Or would it just be easier t...
Hi, I am running a Python code and I get the following error message:
Exception exceptions.ReferenceError: 'weakly-referenced object no longer exists' in <bound method crawler.__del__ of <searchengine.crawler instance at 0x2b8c1f99ef80>> ignored
Does anybody know what can it means?
P.S.
This is the code which produce the error:
impo...
If I have the following code:
import sqlite
sqlite.connect('tmp.db').cursor().close()
I get the following error message:
Traceback (most recent call last):
File "searchengine2.py", line 13, in ?
sqlite.connect('tmp.db').cursor().close()
File "/usr/lib64/python2.4/site-packages/sqlite/main.py", line 280, in close
if self.c...
I am working on a project using Hadoop and it seems to natively incorporate Java and provide streaming support for Python. Is there is a significant performance impact to choosing one over the other? I am early enough in the process where I can go either way if there is a significant performance difference one way or the other.
...
Given a set {a,b,c,d} What's a good way to produce {a,b,c,d,ab,ac,ad,bc,bd,cd,abc,abd,abcd}?
A recursive algorithm, I think, but maybe some weird lambda thing would work better. I'm using python.
...
Hi,
I want to submit a form (by POST) that will submit N (unknown) user_id's.
Can I make a view receive those ids as a list?
For example
def getids(request,list):
for id in list:
usr = User.objects.get(pk=id);
//do something with it.
usr.save()
Is
for id in request.POST['id']:
even possible?
I'm lookin...
I'd like to write a simple command line proxy in Python to sit between a Telnet/SSH connection and a local serial interface. The application should simply bridge I/O between the two, but filter out certain unallowed strings (matched by regular expressions). (This for a router/switch lab in which the user is given remote serial access to ...
class FormatFloat(FormatFormatStr):
def __init__(self, precision=4, scale=1.):
FormatFormatStr.__init__(self, '%%1.%df'%precision)
self.precision = precision
self.scale = scale
def toval(self, x):
if x is not None:
x = x * self.scale
return x
def fromstr(self, s):
...
Given a Polymodel in Google App Engine, likeso:
from google.appengine.ext import db
from google.appengine.ext.db import polymodel
class Base(polymodel.PolyModel):
def add_to_referer(self):
Referer(target=self).put()
class Referer(db.Model):
target = db.ReferenceProperty()
@classmethod
def who_referred(cls):
for ...
xrange function doesn't work for large integers:
>>> N = 10**100
>>> xrange(N)
Traceback (most recent call last):
...
OverflowError: long int too large to convert to int
>>> xrange(N, N+10)
Traceback (most recent call last):
...
OverflowError: long int too large to convert to int
Python 3.x:
>>> N = 10**100
>>> r = range(N)
>>> r = r...
I am running a little program in python that launches a small window that needs to stay on top of all the other windows. I believe this is OS specific, how is it done in GNU-Linux with GNOME?
[Update - Solution for Windows]
Lovely, I think I got it working. I am using Python 2.5.4 with Pygame 1.9.1 in Eclipse on Vista 64-bit. Thus, thi...
I want to be able to download an image (to my computer or to a web server) resize it, and upload it to S3. The piece concerned here is:
What would be a recommended way to do the downloading portion within Python (i.e., don't want to use external tools, bash, etc). I want it to be stored into memory until it's done with (versus downloadi...
I'm using SQLAlchemy and I can create tables that I have defined in /model/__init__.py but I have defined my classes, tables and their mappings in other files found in the /model directory.
For example I have a profile class and a profile table which are defined and mapped in /model/profile.py
To create the tables I run:
paster setu...
Hi,
I want to use a tuple (1,2,3) as a key using the shelve module in Python. I can do this with dictionaries:
d = {}
d[(1,2,3)] = 4
But if i try it with shelve:
s = shelve.open('myshelf')
s[(1,2,3)] = 4
I get: "TypeError: String or Integer object expected for key, tuple found"
Any suggestions?
...
In Python, how do you return a variable like:
function(x):
return x
Without the 'x' (') being around the x? Thanks.
...
Are there any 3d game engines for these ?
...