text stringlengths 226 34.5k |
|---|
Python insert text after last match in search
Question: I would like to find the last line matching a certain pattern, in python. What
I am trying to do is find the last line that contains a certain item
(line_end), and insert a block of information as a few new lines after it. So
far I have:
text = ope... |
Why my merge sort in python exceeded maximum recursion depth?
Question: I am learning MIT's open course 6.046 "Introduction to Algorithms" in Youtube,
and I was trying to implement the merge sort in python.
My code is
def merge(seq_list, start, middle, end):
left_list = seq_list[start:middle]
... |
Django django-extensions commands unavailable ( graph_models )
Question: I'm trying to install django-extensions + graphviz + pygraph but i can't. I
have done the following steps ( under Ubuntu ):
sudo apt-get install graphviz libgraphviz-dev graphviz-dev python-pygraphviz
in the project virtualenv... |
Intersection in sqlite3 in Python
Question: I am trying to extract data that corresponds to a stock that is present in
both of my data sets (given in a code below).
This is my data:
#(stock,price,recommendation)
my_data_1 = [('a',1,'BUY'),('b',2,'SELL'),('c',3,'HOLD'),('d',6,'BUY')]
#(stock... |
Trying to make simple minesweeper game in python
Question: Trying to make simple minesweeper game in python, but have one problem. I have
a 7x7 board of x's and when the player enters a row and column it deletes the
column and replaces it with a -. I also tried to have a 1 appear if the
players guess one space away, bu... |
python keyring download error
Question: I keep getting this error when I try to install a package:
Download error on http://keyring-python.org/: (-2, 'Name or service not known') -- Some packages may not be found!
Download error on http://home.python-keyring.org/: (-3, 'Temporary failure in name reso... |
python csv write only certain fieldnames, not all
Question: I must be missing something, but I don't get it. I have a csv, it has 1200
fields. I'm only interested in 30. How do you get that to work? I can
read/write the whole shebang, which is ok, but i'd really like to just write
out the 30. I have a list of the field... |
Python fastest way to find values in big data
Question: I have a huge database with rows structured by the fields "date, ad, site,
impressions, clicks"
I got all of them via python using:
cursor.execute(select * from dabase)
data = cursor.fetchall()
From all this data, I need to sample only th... |
Multiplexing string of numbers in python for the parallel port
Question: I'm trying to do something like
[this](http://www.youtube.com/watch?v=BB9E67KfvFw). The problem is that i
can't build the loop that does that.

Here is my code:
import parallel
im... |
Setting the log level causes fabric to complain with 'No handlers could be found for logger "ssh.transport"'
Question: The following script:
#!/usr/bin/env python
from fabric.api import env, run
import logging
logging.getLogger().setLevel(logging.INFO)
env.host_string = "%s@%s... |
Numpy needs the ucs2
Question: I have installed Numpy using ActivePython and when I try to import numpy
module, it is throwing the following error:
> ImportError: /opt/ActivePython-2.7/lib/python2.7/site-
> packages/numpy/core/multiarray.so: undefined symbol:
> PyUnicodeUCS2_FromUnicode
I am fairly new to python, and... |
Fabric error when connecting to multiple hosts with ssh config file & RSA keys
Question: I have an error when i connect to multiple servers with Fabric using RSA keys
and ssh config file. My client is snow leopard 10.6.8 with python 2.7.2,
Fabric 1.4.0, ssh (library) 1.7.13. I use multiple RSA keys with passphrase
(usi... |
Server returns 403 error after submitting a form?
Question: So I just recently bought some web hosting and I'm trying to get my site setup
and when I try submitting the form I get a "`Forbidden (403) CSRF verification
failed. Request aborted.`" And then it emails me the details on what went
wrong and it says "`ViewDoes... |
Unique lists from a list
Question: Given a list I need to return a list of lists of unique items. I'm looking to
see if there is a more Pythonic way than what I came up with:
def unique_lists(l):
m = {}
for x in l:
m[x] = (m[x] if m.get(x) != None else []) + [x]
return... |
Run django application on apache with uWSGI
Question: I wanted to run my django application using apache and uWSGI. So I installed
apache which use worker_module. When I finally run my app and tested its
performance using httperf I noticed that system is able to serve only one user
at the same time. The strange thing i... |
Add image to .spec file in Pyinstaller
Question: Does anybody know how to modify the `.spec` file created with the
`Makespec.py` of Pyinstaller such that it includes an image data in the
`_MEIPASS2` Temp dir? I want to be able to add an icon to my exe. I've done
what's written [here](http://stackoverflow.com/questions/... |
Input from Serial (FTDI) to a php/python script
Question: I and some other people are working on a project that includes using an
Arduino with an Ubuntu Server (running Ubuntu 10.04 64 bit). Currently we have
the device connected and we can see the Arduino putting data in /dev/ttyUSB0.
I can successfully cat it to anot... |
Python: Import Source Code into Eclipse
Question: I've recently started using `eclipse` for my class over `IDLE`. So far I have
no problems writing new code and creating new projects in eclipse.
However, when I open older code that was not originally written in my current
project, eclipse seems to only open it as a te... |
Escape PCRE metacharacters in Haskell
Question: Do any of the Haskell PCRE libraries provide a function to escape regex
metacharacters in a string? I.e. a function to take a string like "[$100]" and
turn it into "\\[\$100\\]".
I'm looking for the equivalent of Python's
[re.escape](http://docs.python.org/library/re.htm... |
PyDev is trying to import non-test-related files?
Question: When I try to auto-discover and run my tests in PyDev I get many import
errors...
For example:
Finding files... done.
Importing test modules ... Traceback (most recent call last):
File "C:\Users\User\Documents\eclipse\dropins\plugins\... |
Virtual Memory Page Replacement Algorithms
Question: I have a project where I am asked to develop an application to simulate how
different page replacement algorithms perform (with varying working set size
and stability period). My results:


 and .read() is different?
Question: This is a newbie question, but I looked around and I'm having trouble finding
anything specific to this question (perhaps because it's too simple/obvious to
others).
So, I am working through Zed Shaw's "Learn Python the Hard Way" and I am on
exercise 15. Th... |
In Python, is there a way to validate a user input in a certain format?
Question: In python, I'm asking the user to input an office code location which needs to
be in the format: XX-XXX (where the X's would be letters)
How can I ensure that their input follows the format, and if it doesn't ask
them to input the office... |
Cannot import PyBrain after installation on OSX 10.6.8
Question: Check the python version
✈ python --version
Python 2.7.2
List the packages within the `virtualenv`
✈ pip freeze
PyBrain==0.3
numpy==1.6.1
scipy==0.10.1
wsgiref==0.1.2
Load the intepreter
... |
How do I use Python to pack a big integer treating four characters as an unsigned long in network byte order as Ruby's .pack("N") does?
Question: This is the bit of Ruby I want to implement in Python:
Base64.urlsafe_encode64([Digest::MD5.hexdigest(url).to_i(16)].pack("N")).sub(/==\n?$/, '')
You see... |
Manipulating DateTime and TimeDelta objects in python
Question: I am wondering how to manipulate Datetime and Time delta objects. I am writing
a game where different planets have different timescales. And I was wondering
how it might be possible to mod datetime objects.
For example if I have a date time object - some ... |
Can I still use StringIO when the containing Writer() closes it?
Question: I am using the [Python avro library](http://pypi.python.org/pypi/avro/1.6.3).
I want to send an avro file over http, but I don't particularly want to save
that file to disk first, so I thought I'd use StringIO to house the file
contents until I'... |
Python argument parser list of list or tuple of tuples
Question: I'm trying to use argument parser to parse a 3D coordinate so I can use
--cord 1,2,3 2,4,6 3,6,9
and get
((1,2,3),(2,4,6),(3,6,9))
My attempt is
import argparse
parser = argparse.ArgumentParser(... |
How to use the python interpreter in chef
Question: I am trying to use the python interpreter in chef. Below is my naive attempt
that did not work. What is the proper way to accomplish the below in python?
script "install_something" do
interpreter "python"
user "root"
cwd "/tmp"
c... |
Efficiently Reshaping/Reordering Numpy Array to Properly Ordered Tiles (Image)
Question: I would like to be able to somehow reorder a numpy array for efficient
processing of tiles.
what I got:
>>> A = np.array([[1,2],[3,4]]).repeat(2,0).repeat(2,1)
>>> A # image like array
array([[[1, 1, 2, 2],... |
How do I check Active Directory user credentials using LDAP?
Question: I am looking for a basic ldap script that is checking if an Active Directory
for a user/password combination.
I mention that, the authentication to LDAP is done using another account than
the ones being verified.
Here is my incomplete script:
... |
Path routing in Flask
Question: I want to run a Python CGI on a shared hosting environment. I followed Flask's
example and came up with a tiny application as below:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
@app.rout... |
Python - Classes and OOP Basics
Question: I do not fully understand classes. I have read the python documentation and
several other tutorials. I get the basic gist of it but don't understand the
nuance. For instance in my code here:
class whiteroom():
""" Pick a door: red, blue, green, or black. ... |
Python function won't start
Question: I'm writing a python calculator, here is the code:
#Python Calculator
import sys;
import cmath;
def plus():
num1 = float(input("Input the first number: "));
num2 = float(input("Input the second number: "));
ans = (num1 + ... |
Idiomatic form of dealing with un-initialized var
Question: I'm coding up my first Scala script to get a feel for the language, and I'm a
bit stuck as to the best way to achieve something.
My situation is the following, I have a method which I need to call N times,
this method returns an Int on each run (might be diff... |
Python "classobj" error
Question: I have this code and I couldn't run it because i get this error: "TypeError:
'classobj' object is not subscriptable" and here is my code:
import cgi
import customerlib
form=cgi.FieldStorage
history = customerlib.find(form["f_name"].value,form["l_nam... |
How to create a grammar to the following data using Pyparsing
Question: I have data similar to YAML and need to create a grammar for it using
Pyparsing. Like Python, Yaml's data scope is defined by the whitespace
data:
object : object_name
comment : this object is created first
methods:
... |
How to send an email containing greek characters using rJython?
Question: The following function (found [here](http://r.789695.n4.nabble.com/Email-out-
of-R-code-tp3530671p3948061.html)) works well for messages containing ASCII
characters. Can you help me modify it for multilingual messages too, because I
don't know py... |
Python 3: Using a multiprocessing queue for logging
Question: I've recently been given the challenge of working multiprocessing into our
software. I want a main process to spawn subprocesses, and I need some way of
sending logging information back to the main process. This is mainly because a
module we use writes warni... |
Boost::Python Forward Declaration of boost::python::object throwing python TypeError
Question: I'm trying to refactor parts of my project, particularly the Python/C++
interface. The standard boost::python python initialization was working
before:
boost::python::object main_module = boost::python::import(... |
Python Frequency Distribution (FreqDist / NLTK) Issue
Question: I'm attempting to break a list of words (a tokenized string) into each
possible substring. I'd then like to run a FreqDist on each substring, to find
the most common substring. The first part works fine. However, when I run the
FreqDist, I get the error:
... |
Python cgi script inserts only integers into mysql database
Question: I started scripting in Python and I ran a into weird problem.
I am trying to insert some values into mysql database. Database fields are
varchar, utf-8 unicode
Using Python 3.2 and wamp server 2.2(apache 2.2.21, mysql 5.5.20)
If I try print(ime), ... |
Datetime comparison behavior in python
Question: Hi I am writing a program that is dependent on time and observing some curious
behavior with datetime objects I cannot quite figure out. The code I am
working with / am having trouble with is...
now = datetime.now()
time_changed_state = some datettime ... |
python regular expression match comma
Question: In the following string,how to match the words including the commas
1. \--
process_str = "Marry,had ,a,alittle,lamb"
import re
re.findall(r".*",process_str)
['Marry,had ,a,alittle,lamb', '']
2. \--
process_str="192.168... |
Is it possible to pass arguments to a python made exe at runtime?
Question: I'm experimenting with file I/O. I have a small practice program that creates
a text file when run. I packaged it with pyinstaller so that double clicking
on the exe creates a new folder and places a text file with "hello world"
inside of it. E... |
Tkinter Button does not appear on TopLevel?
Question: This is a piece of code I write for this question: [Entry text on a different
window?](http://stackoverflow.com/questions/10051721/how-to-fetch-the-entry-
text-on-a-different-window/10051863#10051863)
It is really strange what happened at `mySubmitButton`, it appea... |
Python C++ extension with SWIG - calling a function by importing module
Question: how can I write an C++ lib and make it to an python extension with SWIG and by
importing the module `import module` it will automaticaly call an function
that initializes some global variables.
I have tried to rename the function to `__i... |
Finding the Maximum Route in a given input
Question: I have this as a homework and i need to do it in python.
Problem:
The Maximum Route is defined as the maximum total by traversing from the tip of the triangle to its base. Here the maximum route is (3+7+4+9) 23.
3
7 4
2 4 6
8 5... |
How do I call Dajax / Dajaxice functions from my Django template
Question: I am writing a simple Django application and wish to add ajax paging using
Dajax / Dajaxice. I have started by trying to implement the simple paging
example from the Dajax website (http://dajaxproject.com/pagination/) - but
haven't managed to ge... |
Python 2.7 on System, PIP and Virtualenv still using 2.6 - How do I switch them to use 2.7
Question: I am on MacOSx 10.6.8 and I have python 2.7 installed
python -v produces:
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "he... |
multiline gtk.Label ignores xalign=0.5
Question: A gtk.Label can't be aligned in center when line-wrap is turned on. Example
code:
import pygtk
pygtk.require('2.0')
import gtk
class testwin(gtk.Window):
def __init__(self):
gtk.Window.__init__(self)
width,height... |
Accessing Items In a ordereddict
Question: Lets say I have the following code:
import collections
d = collections.OrderedDict()
d['foo'] = 'python'
d['bar'] = 'spam'
Is there a way I can access the items in a numbered manner, like:
d(0) #foo's Output
d(1) #bar's Outpu... |
wsgi django not working
Question: im installing django,
the test for wsgi is ok, but when i point my default file to the django test,
it doesnt work,
this is the test that works fine:
default: `/etc/apache2/sites-available/default`
<VirtualHost *:80>
ServerName www.example.com
ServerAl... |
How to install python packages in virtual environment only with virtualenv bootstrap script?
Question: I want to create a bootstrap script for setting up a local environment and
installing all requirments in it. I have been trying with
virtualenv.create_bootstrap_script as described in their
[docs](http://pypi.python.o... |
i update djang1.3.1 to djang1.4 , error: MOD_PYTHON ERROR
Question: I updated djang1.3.1 to djang1.4.
In my local env ,that's fine.
but when i ci my code to server ,error happened!
in my server , i can use 'python manage.py shell'
and can 'import settings', that's all right,
but still have this error, who can... |
Running profile startup files in an embedded IPython instance
Question: I want to use an embedded IPython shell with a user_ns dictionary and a my
profile configuration (ipython_config.py and the startup files). The purpose
is to run a Django shell with models imported on startup. django-extensions
implements a command... |
date.timestamp not found in python?
Question: After changing the import as a from-import i'm running into this error:
from datetime import datetime, date, timedelta
today = date.today()
from time import mktime
from feedparser import feedparser
import settings
def check_calendar()... |
Post request with multipart/form-data in appengine python not working
Question: I'm attempting to send a multipart post request from an appengine app to an
external (django) api hosted on dotcloud. The request includes some text and a
file (pdf) and is sent using the following code
from google.appengine.... |
Gnuplot: line 0: function to plot expected
Question: I've a python script who generate a graphic with gnuplot. But I've an error:
gnuplot> plot ^ line 0: function to plot expected
g=Gnuplot.Gnuplot(persist=1)
g.title('Read&Write Performance')
g.xlabel('minutes')
g.ylabel('MB/... |
Python: Using sympy.sympify to perform a safe eval() on mathematical functions
Question: I am writing a program where users need to be able to use self written
mathematical functions containing functions from numpy and scipy, eg.
**scipy.special.wofz()**.
These functions will be stored in files and imported as strings... |
Thousands Separator in Python
Question: > **Possible Duplicate:**
> [how to print number with commas as thousands separators in Python
> 2.x](http://stackoverflow.com/questions/1823058/how-to-print-number-with-
> commas-as-thousands-separators-in-python-2-x)
Does anyone know of an easier way to make numbers have th... |
Python: Strange behavior of datetime.astimezone with respect to US/Pacific and America/Los_Angeles time zones?
Question: Please, observe:
C:\dev\poc\SDR>python
Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" fo... |
Python Regular Expressions: Capture lookahead value (capturing text without consuming it)
Question: I wish to use regular expressions to split words into groups of `(vowels,
not_vowels, more_vowels)`, using a marker to ensure every word begins and ends
with a vowel.
import re
MARKER = "~"
VO... |
Socket receiving no data. Why?
Question: I was learning socket programming and tried to design a basic http client of
mine. But somehow everything is going good but I am not receiving any data.
Can you please tell me what am I missing?
**CODE**
import socket
def create_socket():
return ... |
date matching using python regex
Question: What am i doing wrong in the below regular expression matching
>>> import re
>>> d="30-12-2001"
>>> re.findall(r"\b[1-31][/-:][1-12][/-:][1981-2011]\b",d)
[]
Answer: `[1-31]` matches `1-3` and `1` which is basically 1, 2 or 3. You cannot match... |
Reload all modules in a directory
Question: I need to reload all the python modules within a specified directory.
I've tried something like this:
import sys, os
import_folder = "C:\\myFolder"
sys.path.insert( 0 , import_folder )
for dir in os.listdir(import_folder):
name = os.path.sp... |
python/bottle and returning a dict
Question: I am using python/bottle to return a dict/json to my android app ( the app
using GSON to parse into JSON). It doesn't seem to parse the python text
correctly.
Here is what python returns:
[{u'slot': -1.0, u'rnd': -1.0}]
But Gson sets slot = 0 and round ... |
Problems with superscript using Python tkinter canvas
Question: I am trying to use canvas.create_text(...) to add text to a drawing. I have
been somewhat successful using unicode in the following way:
mytext = u'U\u2076' #U^6
canvas.create_text(xPos,yPos,text = mytext, font = ("Times","30")
canv... |
csvkit & django a.k.a. using csvkit as modules instead of from command line
Question: I need to do some csv file processing in a django app.
I heard about csvkit and it looks pretty cool.
[github page](https://github.com/onyxfish/csvkit)
Want to try it out but I don't know how to consume csvkit as a module.
Specif... |
Set a integer limit in a entry widget in tkinter (python)
Question: How do I make it so that if person enters a number higher than 3000, it prints
out a custom message instead of calculating the factorial of that certain
number?
I've tried 'if number > 3000, print "blah blah blah"', but it doesn't work.
Think it has s... |
Using boost 1_48 with Apache qpid on Windows
Question: I stuck while trying to compile **qpid** c++ with **boost 1_47_0** using
**Visual Studio 2010**. Here is steps sequence, that I made:
1. Built _boost 1.48.0_
2. Added BOOST_ROOT, BOOST_INCLUDEDIR, BOOST_LIBRARYDIR, etc. to %PATH% env. variable
3. Installed _... |
easy_install matplotlib updates on Mac OS X
Question: I'm currently using matplotlib 1.0.1, running with Python 2.7.1, but like to
update it to at least 1.1.0. However, when I tried downloading
matplotlib-1.1.0-py2.7-python.org-macosx10.3.dmg from
<http://sourceforge.net/projects/matplotlib/files/matplotlib/>,
the su... |
Moving matplotlib legend outside of the axis makes it cutoff by the figure box
Question: I'm familiar with the following questions:
[Matplotlib savefig with a legend outside the
plot](http://stackoverflow.com/questions/8971834/matplotlib-savefig-with-a-
legend-outside-the-plot)
[How to put the legend out of the
plot]... |
Python NumPy Convert FFT To File
Question: I was wondering if it's possible to get the frequencies present in a file with
NumPy, and then alter those frequencies and create a new WAV file from them? I
would like to do some filtering on a file, but I have yet to see a way to read
a WAV file into NumPy, filter it, and th... |
Propagate system call interruptions in threads
Question: I'm running two python threads (`import threading`). Both of them are blocked
on a `open()` call; in fact they try to open named pipes in order to write in
them, so it's a normal behaviour to block until somebody try to read from the
named pipe.
In short, it loo... |
Displaying inline images on iPhone, iPad
Question: I'm trying to create an email in Django with inline images.
msg = EmailMultiAlternatives(...)
image_file = open('file_path', 'rb')
img = MIMEImage(img_data)
image_file.close()
img.add_header('Content-ID', '<image1>')
img.add_header(... |
How to turn a comma-delimited list of date attributes into a MySQL date value?
Question: Not sure if I've worded my title correctly but here goes. I have a file of
jobs which are all in a similar format to this:
423720,hparviz,RUN,512,22,Mar,10:38,11,April,14:06
Basically from this I need to covert... |
Is it possible to get a list of printer names in Windows?
Question: I'm trying to create an automatic printer installer for Windows.
If I wanted to pull a list of printers, how would I go about that in Python? I
know there's a way to get a list using a VB script on the command line, but
that gives me additional inform... |
Cannot create test suite for Django
Question: I'm having trouble creating a test suite in Django 1.3.
Say I have an installed app in a directory called `app_name`. One of the files
in that directory is `foo.py` which defines a class named `Foo`. I want to
test that, so I also have a file that directory called `foo_tes... |
python string list to list ast.listeral_eval
Question:
>>> import ast
>>> string = '[Small, Medium, Large, X-Large]'
>>> print string
[Small, Medium, Large, X-Large]
>>> string = ast.literal_eval(string)
Traceback (most recent call last):
File "<pyshell#26>", line 1, in <module>
... |
Sending Hex Values through UDP or TCP socket via parameter passing to script
Question: I know in order to send data through a UDP socket using python has to be in
the following format "\x41" = A .
I have a python script udp_send.py and I want to send in a hex value to
represent a register value on the server side.
I ... |
How to keep a C++ class name unmodified with Cython?
Question: I have a C++ class called Foo. If I follow the [Cython C++
tutorial](http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html) I will
need to call the Python class differently, PyFoo for example. However I really
need to call the Python class Foo as wel... |
Pack array of namedtuples in PYTHON
Question: I need to send an array of namedtuples by a socket.
To create the array of namedtuples I use de following:
listaPeers=[]
for i in range(200):
ipPuerto=collections.namedtuple('ipPuerto', 'ip, puerto')
ipPuerto.ip="121.231.334.22"
... |
What modules should I use to create a game tree?
Question: I'm writing a project for a Python coding class and I have a question. I'm
writing a [Reversi](http://en.wikipedia.org/wiki/Reversi) engine that will
look several moves ahead in a game and then pick the move that it thinks is
best. While I understand that pytho... |
Using Requests python library to connect Django app failed on authentication
Question: Maybe a stupid question here: Is Requests(A python HTTP lib) support Django
1.4 ?
I use **Requests** follow the Official Quick Start like below:
requests.get('http://127.0.0.1:8000/getAllTracks', auth=('myUser', 'myPa... |
Scrapping: How to fetch an attribute in a <abbr> tag
Question: I am using **lxml and python** to scrap through a page. The link to the page
is **[HERE](http://www.insiderpages.com/b/3721895833/central-kia-of-irving-
irving)**. The hiccup I face right now is how to fetch the attribute in the
tag. For example the 3 Gold ... |
python: unable to specify relative path for dll import
Question: I am trying to load a dll in python, and can only do so if I enter the
absolute path. I would like to use a relative path, or environment variables.
The only thing that works is if I specify the exact path (C:...) I even tried
to get the dll to build dire... |
matplotlib bar plot errbar
Question: in the official example,we can use bar function like this:
#!/usr/bin/env python
# a stacked bar plot with errorbars
import numpy as np
import matplotlib.pyplot as plt
N = 5
menMeans = (20, 35, 30, 35, 27)
womenMeans = (25, 32, 34, ... |
python websocket handshake (RFC 6455)
Question: I am trying to implement a simple websoket server on python, using RFC 6455
protocol. I took handshake format from
[here](http://en.wikipedia.org/wiki/WebSocket#WebSocket_protocol_handshake)
and [here](http://tools.ietf.org/html/rfc6455#section-1.3).
I am using Chromium ... |
Unable to write into files
Question: This is a bit strange. My program isn't able to write the output to a file.
Its even not showing any error. I simultaneously used standard output and
found that its showing..
This is my code: (Python 2.7)
#!/usr/bin/env python
import re
def isR... |
GAE datastore - count records between one minute ago and two minutes ago?
Question: I am using GAE datastore with python and I want to count and display the
number of records between two recent dates. for examples, how many records
exist with a time signature between two minutes ago and three minutes ago in
the datasto... |
How do I get the visitor's current timezone then convert timezone.now() to string of the local time in Django 1.4?
Question: I understand that the best practice now with Django 1.4 is to store all
`datetime` in UTC and I agree with that. I also understand that all timezone
conversation should be done in the template le... |
Python thread waiting for copying the file
Question: I have a c program which is running in thread and appending some data in a
file. I want to run a python thread which will copy the same file(which c
thread is writing) after some time interval. Is there any safe way to do this?
I am doing this in linux OS.
Answer: ... |
Django MongoDB Engine DebugCursor "not JSON serializable"
Question: Trying to serialize a MongoDB cursor in Django
import json
from pymongo import json_util
results = json.dumps(results, default=json_util.default, separators=(',', ':'))
Where the original `results` is something like
... |
How to send an HTTP request from a Mac app to a Django server?
Question: I want to send an HTTP request like:
"http://.../mydjangosite?var1=value1&var2=value2&var3=value3"
to my Django server and want this last to send response with a boolean value
`"1"` if `value1,2,3` are equal to the ones in my ... |
add boxplot to other graph in python
Question: 
These two graphs have exactly the same x axis value of each point, is it
possible to display the box whisker on top of the first graph?
I tried this:
fig1 = plt.figure()
ax = f... |
Dymo Label Printer from QWebview?
Question: I am attempting to use the Dymo example pages to print a label from a QWebview
in a Python/Qt based application. The example works fine in a major browser
(IE, FF, Chrome have been tested). However, when the example page is loaded in
the QWebview, I get the following error:
... |
TypeError: cannot concatenate 'str' and 'type' objects
Question: Before I get to my issue, I have searched around for an answer but cannot seem
to find anything specific to my case.
Ok, basically I call my script via cmd and pass in 16 args and use them to set
some variables I have. I am creating a custom html report ... |
Efficient iteration over a list representation of multidimensional indices (of arbitrary dimension)
Question: I work with multidimensional structures of arbitrary dimension. I have a
Python list of `xrange` iterators, with each iterator representing an index of
a multidimensional array:
indices = [ i, j,... |
Threading serializable operations in python is slower than running them sequentially
Question: I am attempting to have two long running operations run simultaneously in
python. They both operate on the same data set, but do not modify it. I have
found that a threaded implementation runs slower than simply running them ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.