I have recently stumbled over a seeming inconsistency in Python's way of dealing with else clauses in different compound statements. Since Python is so well designed, I'm sure that there is a good explanation, but I can't think of it.
Consider the following:
if condition:
do_something()
else:
do_something_else()
Here, do_someth...
I have the following PyObjC script:
from Foundation import NSObject
import QTKit
error = None
capture_session = QTKit.QTCaptureSession.alloc().init()
print 'capture_session', capture_session
device = QTKit.QTCaptureDevice.defaultInputDeviceWithMediaType_(QTKit.QTMediaTypeVideo)
print 'device', device, type(device)
success = device.open_...
I'm following a tutorial of making desktop apps. with python and qt4, I downloaded and installed qt creator ide, created the .ui file and then I had to convert it using pyuic4, I've been trying a lot of things and still can't do it.
I thought that pyuic4 would be installed with Qt creator IDE, but it seems that's not the case, so I inst...
Hi,
I've got a library written in C++ which I wrap using SWIG and use in python. Generally there is one class with few methods. The problem is that calling these methods may be time consuming - they may hang my application (GIL is not released when calling these methods). So my question is:
what is the simplest way to release GIL for t...
Hi
I am experiencing issues with my SVN post-commit hook and the fact that it is executed with an empty environment. Everything was working fine till about two weeks ago when my systems administrator upgraded a few things on the server.
My post-commit hook executes a Python script that uses a SVN module to email information about the ...
In Python. r^[\w*]$
whats that mean?
...
I understand that
* = "zero or more"
? = "zero or more" ...what's the difference?
Also, ?: << my book uses this, it says its a "subtlety" but I don't know what exactly these do!
...
def fun1(a):
for i in range(len(a)):
a[i] = a[i] * a[i]
return a
...
Hi everyone!
is there a way to rotate a PDF 90 degrees losslessly, with Python or using the command line?
I'm looking for a REAL rotation, not just adding a "/ROTATE 90" inside the PDF, because afterwards I have to send the PDF via Hylafax and it looks like that it ignores those commands.
I tried with ImageMagick's convert but the qual...
def fun1(a,x):
z = 0
for i in range(len(a)):
if a[i] == x:
z = z + 1
return z
...
I need to create a desktop app that will work with Windows and Gnome(Ubuntu). I would like to use Python to do this. The GUI part of the app will be a single form with a message area and a couple of buttons.
The list of GUI's for Python seems overwhelming. I am looking for something simple if possible, the main requirements is it mus...
Hello, I'm searching in a HTML document using XPath from lxml in python. How can I get the path to a certain element? Here's the example from ruby nokogiri:
page.xpath('//text()').each do |textnode|
path = textnode.path
puts path
end
print for example '/html/body/div/div[1]/div[1]/p/text()[1]' and this is the string I want to ...
Hello,
I 'am new to lxml, quite new to python and could not find a solution to the following:
I need to import a few tables with 3 columns and an undefined number of rows starting at row 3.
When the second column of any row is empty, this row is discarded and the processing of the table is aborted.
The following code prints the table...
I need all the weekdays between two days.
Example:
Wednesday - Friday = Wednesday, Thursday, Friday
3 - 5 = 3, 4, 5
Saturday - Tuesday = Saturday, Sunday, Monday, Tuesday
6 - 2 = 6, 7, 1, 2
I'm pretty sure there is a clever algorithm out there to solve this. The only algorithms I can think of use eit...
Hello. Consider the following snippet:
import lxml.html
html = '<div><br />Hello text</div>'
doc = lxml.html.fromstring(html)
text = doc.xpath('//text()')[0]
print lxml.html.tostring(text.getparent())
#prints <br>Hello text
I was expecting to see '<div><br />Hello text</div>', because br can't have nested text and is "self-closed" (I...
Hello, I have had some issues with downtime as a result of hitting the max_user_connections limit in MySql.
The default connection timeout is 8 hours, so once we hit the limit (and having no access to kill the connections on our shared hosting) I simply had to wait 8 hours for the connections to time out.
I would like to add the follow...
Hi there,
I want to provide my colleagues with an interface (using Windows Forms or WPF) to control the states of virtual machines (KVM based) on a linux host. On the command line of this server, I'm using a tool, called libvirt, which provides python bindings to access its functionality.
What whould be the best pratice to remotely acce...
This may be more of a serverfault question I'm not sure.
I have two practically identical servers - I cloned the DB from one to the other, and now when I try to delete a user in the Admin > Auth application Django gives the following error:
{code}
File "/usr/lib/python2.5/site-packages/django/db/models/sql/query.py", line 206, in resul...
My situation is something like this:
class AbstractClass:
def __init__(self, property_a):
self.property_a = property_a
@property
def some_value(self):
"""Code here uses property_a but not property_b to determine some_value"""
@property
def property_a(self):
return self.property_a
@prope...
Hi SO's,
Many thanks for the advice you have given me thus far. Using testbenches is something this forum has really shown me the light on and for that I am appreciative. My problem is that I am playing with a singleton and normally I won't del it, but in a testbench I will need to. So can anyone show me how to del the thing? I've s...