I am using a wxPython wx.html.HtmlWindow to display part of my interface. The user can scroll down a list of links in a window smaller than the list. When they click on a link, I need to repaint the web page, but I want to return the page position back to where they clicked it.
I've tried MouseEvent.GetLogicalPosition() on the event, b...
I'm trying to write a class for a read-only object which will not be really copied with the copy module, and when it will be pickled to be transferred between processes each process will maintain no more than one copy of it, no matter how many times it will be passed around as a "new" object. Is there already something like that?
...
I am working on a quite large code base that has been implemented using sqlalchemy.ext.declarative, and I need to add a dict-like property to one of the classes. What I need is the same as in this question, but in a declarative fashion. Can anyone with more knowledge in SQLAlchemy give me an example?
Thanks in advance...
...
It seems so "dirty" emptying a list in this way:
while len(alist) > 0 : alist.pop()
Does a clear way exist to do that?
...
str = QtCore.QString('Hello')
AttributeError: 'module' object has no attribute 'QString'
QtCore.QString._init_(self)
AttributeError: 'module' object has no attribute 'QString'
Yes, I'm read QString Class Reference
if you can, answer with code sample. Thanks
...
class LineItemInline(admin.TabularInline):
model = LineItem
extra = 10
class InvoiceAdmin(admin.ModelAdmin):
model = Invoice
inlines = (LineItemInline,)
and
class LineItem(models.Model):
invoice = models.ForeignKey(Invoice)
item_product_code = models.CharField(max_length=32)
item_description = models.CharF...
I'm have functions that contribute small parts of a figure generation. What I'm trying to do is to use these functions to generate multiple figures? So something like this:
work with Figure 1
do something else
work with Figure 2
do something else
work with Figure 1
do something else
work with Figure 2
If anyone could help, that'd be ...
I am trying to understand crc32 to generate the unique url for web page.
If we use the crc32, what is the maximum number of urls can be used so that we can avoid duplicates?
What could be the approximative string length to keep the checksum to be 2^32?
When I tried UUID for an url and convert the uuid bytes to base 64, I could reduce ...
How can you get the number of affected rows from executing a "MERGE INTO..." sql command within CX_Oracle?
When ever I execute the MERGE SQL on cx_oracle, I get a cursor.rowcount of -1. Is there a way to get the number of rows affected by the merge?
...
I'm using BerkeleyDB to develop a small app. And I have a question about opening a database multiple time in BDB.
I have a large set of text ( corpus ), and I want to load a part of it to do the calculation. I have two pseudo-code (mix with python) here
@1
def getCorpus(token):
DB.open()
DB.get(token)
DB.close()
@2
#ope...
Okay. So I have about 250,000 high resolution images. What I want to do is go through all of them and find ones that are corrupted. If you know what 4scrape is, then you know the nature of the images I.
Corrupted, to me, is the image is loaded into Firefox and it says
The image “such and such image” cannot be displayed, because it c...
I have been using this copy method for quite a while, in lots of classes that needed it.
class population (list):
def __init__ (self):
pass
def copy(self):
return copy.deepcopy(self)
It has suddenly started producing this error:
File "C:\Python26\lib\copy.py", line 338, in _reconstruct
state = deepcopy(state, memo)
...
Why on Earth doesn't the interpreter raise SyntaxError everytime I do this:
my_abc = ['a',
'b',
'c'
'd',]
I just wanted to add 'c' to the list of strings, and forgot to append the comma. I would expect this to cause some kind of error, as it's cleary incorrect.
Instead, what I got:
>>> my_abc
['a', 'b...
Given a class Foo (whether it is a new-style class or not), how do you generate all the base classes - anywhere in the inheritance hierarchy - it issubclass of?
...
I have two points in 3D:
(xa,ya,za)
(xb,yb,zb)
And I want to calculate the distance:
dist = sqrt((xa-xb)^2 + (ya-yb)^2 + (za-zb)^2)
What's the best way to do this with Numpy, or with Python in general? I have:
a = numpy.array((xa,ya,za))
b = numpy.array((xb,yb,zb))
...
To illustrate what I mean by this, here is an example
messages = [
('Ricky', 'Steve', 'SMS'),
('Steve', 'Karl', 'SMS'),
('Karl', 'Nora', 'Email')
]
I want to convert this list and a definition of groups to a list of integers and a lookup dictionary so that each element in the group gets a unique id. That id should map t...
Inspired by this question.
Why is there no list.clear() method in python? I've found several questions here that say the correct way to do it is one of the following, but no one has said why there isn't just a method for it.
del lst[:]
lst[:] = []
While it may go against the "zen of python" to have more than one way of doing somethin...
Looking for a python script that would simply connect to a web page (maybe some querystring parameters).
I am going to run this script as a batch job in unix.
...
I'm trying to add images to my models in my Django app.
models.py
class ImageMain(models.Model):
product = models.ForeignKey(Product)
photo = models.ImageField(upload_to='products')
In development mode, every time I try to upload the image via Django admin, I keep getting:
Upload a valid image. The file you uploaded was either n...
I have some data that I am displaying in 3 column format, of the form "key: value key: key: value key: value". Here's an example:
p: 1 sl: 10 afy: 4
q: 12 lg: 10 kla: 3
r: 0 kl: 10 klw: 3
s: 67 vw: 9 jes: 3
t: 16 uw: 9 skw: 3
u: 47 ug: 9 mjl: 3
v: 37 mj: 8 lza: 3
w: 119 fv: 8 fxg: 3
x: 16 fl: 8 aew: 3...