Am I doing this right? (probably not...someone correct? thanks)
@register.filter('addslashes')
@stringfilter
def addslashes(text, arg):
return text.replace('\'','\\'')
{{ query|addslashes }}
...
I have a wrapper class for an object. I want it to apply all operations applied to it on the wrapped object, e.g wrapper+=a would yield the same result as wrapped+=a, for instance. I want to apply this for all operators. Any simple way to override all operators without overriding each one explicitly?
...
Does anyone know how to implement the VLC Python bindings? I downloaded vlc.py and vlcwidget.py from the VLC wiki (http://wiki.videolan.org/Python_bindings) and tried to run vlcwidget. Other than having vlc installed, do I need to do anything else, or should I just be able to run 'python vlcwidget.py '? Because that is not working for...
{% if is_loggedin OR is_anonymous %}
test message
{% endif %}
...
What is the Python code to create a password encrypted zip file? I'm fine with using some apt-get'able utilities using system on the command line.
...
If you have a method called "set" in a class and want to create a standard builtin "set" object somewhere else in the class, Python seems to reference the method when I do that. How can you be more specific to let Python know you mean the builtin "set", not the method "set"? More specifically, set() is being created in an __exit__ functi...
Hello All,
Disclaimer:
I'm very new to Django. I must say that so far I really like it. :)
(now for the "but"...)
But, there seems to be something I'm missing related to unit testing. I'm working on a new project with an Oracle backend. When you run the unit tests, it immediately gives a permissions error when trying to create th...
I need to be able to save an image (format doesn't matter) of the state of the dc canvas. I tried dc.GetAsBitmap but it returns invalid bitmaps. How can I do it?
...
My question is: where do these patterns (below) originate?
I learned (somewhere) that Python has unique "copies", if that's the right word, for small integers. For example:
>>> x = y = 0
>>> id(0)
4297074752
>>> id(x)
4297074752
>>> id(y)
4297074752
>>> x += 1
>>> id(x)
4297074728
>>> y
0
When I look at the memory locations of ints...
Given this 3D bar graph sample code, how would you convert the numerical data in the x-axis to formatted date/time strings? I've attempted using the ax.xaxis_date() function without success. I also tried using plot_date(), which doesn't appear to work for 3D bar graphs. Here is a modified version of the sample code to illustrate what I a...
Anyone had success installing and using PySide on OSX? I am following the install instructions on the PySide site, though I'm running into issues building the API Extractor. I run cmake on the CMakeLists.txt file inside the api extractor dir and:
This error is thrown-
CMake Error at /Applications/CMake 2.8-0.app/Contents/share/cmake-2...
Hi,
I need to create a unit-test for some python class. I have a database of inputs and expected results which should be generated by the UUT for those inputs.
Here is the psuedo-code of what i want to do:
for i=1 to NUM_TEST_CASES:
Load input for test case i
execute UUT on the input and save output of run
Load expected re...
Hi, I am using Django PyFacebook Middleware to allow users to connect.
def index(request):
FBGRABLIST = ['name', 'pic','uid','first_name','last_name', 'email']
fbdata = []
if request.facebook.check_session(request):
fbdata = request.facebook.users.getInfo(request.facebook.uid, FBGRABLIST)[0]
print fbd...
How can I extract the text content (not images) from a PDF while (roughly) maintaining the style and layout like Google Docs can?
...
I'd like to improve the performance of convolution using python, and was hoping for some insight on how to best go about improving performance.
I am currently using scipy to perform the convolution, using code somewhat like the snippet below:
import numpy
import scipy
import scipy.signal
import timeit
a=numpy.array ( [ range(1000000)...
I'd like to know how can I add .error class to input elements (to registration app) when the form validation fails.
...
Hi Everyone,
I've been trying to follow this blog post to get my python version back to the snow leopard default. I have followed the first two steps without a problem but am lost when it comes to 3 and 4. I installed Python 2.6.4 but I assume the instructions are pretty similar. Thanks for your help!
...
Hi
I am trying to add an object to an array list but since I'm adding the actual object when I try to reset the array thereafter, all the values in the array are reset.
Is there an actual way how I can add a monitor object to the array and change the values and not affect the ones I've already saved in the array?
Thanks
Code:
arrayLi...
I have some data stored in a DB that I want to process. DB access is painfully slow, so I decided to load all data in a dictionary before any processing. However, due to the huge size of the data stored, I get an out of memory error (I see more than 2 gigs being used). So I decided to use a disk data structure, and found out that using s...
Many attempts have been made in the past to add timeout functionality in Python such that when a specified time limit expired, waiting code could move on. Unfortunately, previous recipes either allowed the running function to continue running and consuming resources or else killed the function using a platform-specific method of thread t...