text stringlengths 226 34.5k |
|---|
Seeding the random number Generator In PHP
Question: I m having a application in which i have to select a number out of many
numbers according to their weights. Every time I will select , I have send the
result to flash.I have found a algorithm in python. I have implemented it in
php and was testing for its results. If... |
python's webbrowser launches IE instead of default on windows 7
Question: I'm attempting to launch a local html file from python in the default browser.
Right now my default is google chrome. If I double-click on a .html file,
chrome launches.
When I use python's webbrowser.open, IE launches instead, with a blank addr... |
What is the pythonic way to calculate dot product?
Question: I have two lists, one is named as A, another is named as B. Each element in A
is a triple, and each element in B is just an number. I would like to
calculate the result defined as :
result = A[0][0] * B[0] + A[1][0] * B[1] + ... + A[n-1][0] * B[n-1]
I know ... |
Finding repeats in multiple lists read from CSV File (Python)
Question: Title seems confusing, but let's say I'm working with the following CSV file
('names.csv').
name1,name2,name3
Bob,Jane,Joe
Megan,Tom,Jane
Jane,Joe,Rob
My question is, how would I go about making code... |
How to execute a shell command through Python
Question: I am new to Python programming. I want to execute a shell command "at" from a
Python program. Can any one of the Python gurus help me out? Thanks in
advance.
Answer: The [`subprocess`](http://docs.python.org/library/subprocess.html) module can
be used for this p... |
Python Queues appear to be dying
Question: I have a main process that spawns Processes and then those Processes add jobs
to a Queue which the main process uses to spawn more processes. And, that
works fine for about 20 seconds and then the main process just stops spawning
jobs even though it has plenty of jobs in the q... |
How do I send XML POST data from an iOS app to a Django app?
Question: I am attempting to implement an online leaderboard in a game app for iOS,
using Django to process POST requests from the iDevice and store the scores. I
have figured out how to get Django to serialize the objects to XML, and my
iPhone can read and d... |
Calling Python functions from inline C with scipy.weave
Question: Can I call a python function from inline C code (using weave)?
Motivation: I have a bit of code that I'd like to optimize, and I've
identified the bottleneck in one function. After my usual tricks, I usually
turn to
[scipy.weave.inline](http://docs.scip... |
Setting different reply-to message in Python email/smtplib
Question: I am using Python email and smtplib to send an email from Python. I am doing
this via the Gmail SMTP server using my Gmail credentials. This works fine,
however I would like to specify a `Reply-to` email address different from the
`from` address, so t... |
Python, default keyword arguments after variable length positional arguments
Question: I thought I could use named parameters after variable-length positional
parameters in a function call, but I get a syntax error when importing a
python class I'm writing with the following "get" method, for example:
cl... |
Python wrapper to access Hg, Git and possibly Bazaar repositories?
Question: I'm looking for a Python library that can do basic manipulation of
repositories, but is independent of the backend version control system.
By basic manipulation, I'm referring to: initialize a repo, add files, commit,
pull, push, get current ... |
Python: tell X to reserve screen space for application
Question: I am trying to solve the issue of reserving space on the screen for an
application with X Window Manager (i.e. Linux platforms). I have seen [this
issue addressed and solved for
Gtk](http://stackoverflow.com/questions/3859045/preventing-window-overlap-in-... |
Why do I get an AttributeError when using .count() in python
Question: `array1=[ 0 5 6 6 6 0 6 0 6 8 0 19 24 7 0 4 9 14 12 0 22 17 1 0 19 6 17 4 7 0
17 24 0 6 9 22]`
i=0
while i<23
m= array1.count(i)
i=i+1
`AttributeError: 'numpy.ndarray' object has no attribute 'count'`
Wh... |
How to know the system is Debian or CentOS in Python?
Question: I want to write some install scripts by python, it should know the OS to
choose either **apt** command or **yum** command.
It seems **sys.platform** can tell **'win32'** or the others, but how to know
it is working on Debian or CentOS in Python?
Answer:... |
Python - Cancel timer thread
Question: I'm trying to create a method which runs on a timer in the background of my
main script:
def hello_world(self):
print 'Hello!'
threading.Timer(2,hello_world).start()
if __name__ == "__main__":
try:
hello_world()
... |
display an error message when file is empty - proper way?
Question: hi im slowly trying to learn the correct way to write python code. suppose i
have a text file which i want to check if empty, what i want to happen is that
the program immediately terminates and the console window displays an error
message if indeed em... |
MATLAB-style find() function in Python
Question: In MATLAB it is easy to find the indices of values that meet a particular
condition:
>> a = [1,2,3,1,2,3,1,2,3];
>> find(a > 2) % find the indecies where this condition is true
[3, 6, 9] % (MATLAB uses 1-based indexing)
>> a(find(a... |
Where Should Shared Object Files Be Placed?
Question: I am venturing into the land of creating C/C++ bindings for Python using
pybindgen. I've followed the steps outlined under "Building it ( GCC
instructions )" to create bindings for the sample files:
<http://packages.python.org/PyBindGen/tutorial.html#a-simple-examp... |
Python - AttributeError: index
Question: I am stuck here...
Connecting to t3://localhost:7001 with userid weblogic ... Successfully
connected to Admin Server 'examplesServer' that belongs to domain 'wl_server'.
Warning: An insecure protocol was used to connect to the server. To ensure on-
the-wire security, the SSL p... |
How to install xbmc module for Python
Question: I tried to find the setup script from xbmcscripts.com but apparently that site
is down. Neither 'easy_install' gives a desirable result. I'm running Ubuntu
11.04 and xbmc (Media Center) is installed and working alright. What I
basically need is the ability to import the x... |
How to correctly sort a string with a number inside?
Question: > **Possible Duplicate:**
> [Does Python have a built in function for string natural
> sort?](http://stackoverflow.com/questions/4836710/does-python-have-a-built-
> in-function-for-string-natural-sort)
I have a list of strings containing numbers and I c... |
Easiest Way to Transfer Data Over the Internet, Python
Question: I have two computers, both are connected to the internet. I'd like transfer
some basic data between them (strings, ints, floats). I'm new to networking so
I'm looking for the most simple way to do this. What modules would I be
looking at to do this?
Both... |
PyOpenGL: Rendering... Well... Anything really
Question: I've been working on a project using python with OpenGL for a while now. I
previously posted a similar problem, but I have since done some more research
and switched to non-deprecated functions. Following [this
tutorial](http://duriansoftware.com/joe/An-intro-to-... |
Pickling a list consisting of 'n' 2-tuple values
Question: I want to pickle a list as it takes a long time for me to create the list. The
list consists of "n" 2-tuple values where the first tuple value is a large
dictionary(1k to 10k keys) and the second value is a string. N can be as large
as 100s to 1000s. I would li... |
How to install lxml for python without administative rights on linux?
Question: I just need some packages which dont present at the host machine (and I and
linux... we... we didn't spend much time together...).
I used to install them like:
# from the source
python setup.py install --user
or
... |
ImportError: cannot import name signals
Question: I'm using Django 1.3.0 with Python 2.7.1. In every test I write the following
imports I get the importError above:
from django.utils import unittest
from django.test.client import Client
The full stack trace:
File "C:\Program Fi... |
Unable to import FigureCanvasWxAgg from Matplotlib in Python
Question: I'm using Python x64 with everything installed, but I'm getting an unresolved
import on FigureCanvasWxAgg. I can get up to matplotlib.backends.backend_wxagg
but there's no FigureCanvasWxAgg to import from there.
I've also tried `from matplotlib.bac... |
function is not defined error in Python
Question: I am trying to define a basic function in python but I always get the
following error when I run a simple test program;
>>> pyth_test(1, 2)
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
pyth_test(1, 2)
... |
How to change the user and group permissions for a directory, by name?
Question: [os.chown](http://docs.python.org/library/os.html#os.chown) is exactly what I
want, but I want to specify the user and group by name, not ID (I don't know
what they are). How can I do that?
Answer:
import pwd
import grp
impo... |
Find Version of Binary File
Question: Does anyone know how I can find the version of a binary file that has been
passed to my function?
I got the following code from [this
page](http://www.linuxquestions.org/questions/programming-9/reading-binary-
file-in-python-804296/):
def version(fpath):
f =... |
Python - Calling a function from a class
Question: I'm having some trouble calling a function which is within a class in python.
Here is my folder hierarchy.
~/Code/program/main.py
~/Code/program/dc_functions/dcfunc.py
~/Code/program/dc_functions/**init**.py
Basically, I want to use a function from dcfunc.py in... |
how to deal with timezone differences in ical standard records using python?
Question: I'm trying to process a ical recurrence record from the python gdata api.
>
> DTEND: 20110421T190000
> params for DTEND:
> TZID [u'Europe/London']
> DTSTART: 20110421T180000
> params for DTSTART:
> TZ... |
How to retrict access to myapplication.appspot.com - google app engine?
Question: For a google app engine application, I would like to retrict access to myself
to my website <http://myapplication.appspot.com> but at the same time let my
android phone app users access it. My android phone app use GetValue and
StoreValue... |
wx.Gauge fails to update beyond 25% in Windows, works in Linux
Question: I seem to have nothing but trouble with wxPython and cross-platform
compatibility :(
I have the function below. It's called when the user clicks a button, it does
some work which may take a while, during which a progress gauge is shown in
the sta... |
new sys.path in python
Question: I am having difficulties importing a script from a directory that is not
stored in sys.path. I have a script saved as test.py in a directory called
"Development" and am trying to add the development directory to sys.path so I
can import a function from my current script called index.py.... |
Resizing a wxPython Window
Question: Is it possible to make a wxPython window only re-sizable to a certain ratio? I
know you can disable resizing; however, I'd like it so when the window was
resized it stuck to a certain width to height ratio.
Answer: One obvious way to do this would be to bind `wx.EVT_SIZE` to a fun... |
wxMessageBox with an auto-close timer in wxPython
Question: **Platforms: Windows, OS X
Python Version: Active State Python 2.7
wxPython Version: Version 2.9**
Here is a sample code in which I use a wxMessageBox:
import wx,os
class Frame(wx.Frame):
def __init__(self, parent, id, title)... |
Python Socket Timeout Issue. How do control the flow of this code better?
Question: While working with the sockets library in python 2.7, I am encountering an
issue with getting the code to flow the way I want it to. I'd like the code to
iterate over a range of IP addresses and open a socket connection for each ip
in t... |
How to get formatted date time in python
Question: I want my Linux Filename like this
May-01-0340AM-2011.tar
How can i get the date variable formatted like above in Python
IN bash i write
date1=$(date +"%b-%d-%I%M%p-%G")
Answer: You can use the same formatting string in `strf... |
How to get back a signed string (e.g. md5 hash) using a public-key (x509 certificate)
Question: I'm very new with cryptographic and stuck for 2 days with this problem, I hope
you can help me with.
I try to sign a md5 digest string with the private key of a X509 certificate.
As far as I can see, this works fine. Now I ... |
Convert Python2.6 to Google App Engine compatible (multiprocessing)
Question: I've made a little script in Python which uses multiprocessing. I've thought
of running it on the Google App Engine as a cron-job, but unfortunately Google
App Engine doesn't support multiprocessing. Can anyone help me convert this
into Googl... |
Rewrite issue with configuring Lighttpd with Flask Python framework
Question: I've run and developed my Flask application without incident using its built-
in server. It has worked fine and has been really smooth and fun.
Unfortunately, Lighttpd is, as always, a pain to deploy to. I'm following the
instructions as clos... |
Python: How to read a (static) file from inside a package?
Question: Could you tell me how can I read a file that is inside my python package?
I have a following situation: a package that I load has a number of templates
(text files used as strings) that I want to load from within the program. But
how do I specify the... |
TypeError: AutoProxy object is not iterable - multiprocessing
Question: consider the following server code :
from multiprocessing.managers import BaseManager, BaseProxy
def baz(aa) :
print "aaa"
l = []
for i in range(3) :
l.append(aa)
return l
c... |
Accessing functions with a dot in theior name (eg. "as.vector") using rpy2
Question: I am trying to access the "as.vector" R function from within Python, using
rpy2. Let's say, for the sake of simplicity, that I want to do something as
simple as this using rpy2 (R code):
x <- as.vector(c(1, 2, 3))
... |
Can I install Python 2.7.1 64bit along side of an exsiting 32bit install on OS X?
Question: **Short Description**
Is it possible to install Python 2.7.1 64/32bit from
[python.org](http://www.python.org/download/#id11) on top of an existing
install (from python.org) of Python 2.7.1 32bit?
**Background**
I installed... |
Getting number of Google hits for a larger list of words
Question: I saw some relevant questions for my problem, but no specific answer. In
brief, I have a larger list of words (more than 1000), and I would like to get
number of Google hits for each word. In particular, I read this tread at
[Stackoverflow: Google searc... |
android mobile socket open
Question: Why Socket can be open on the android emulator and connect to the python
server code and open a socket !! In other Hand When i run same android code on
the mobile it doesn't run . didnt open a socket ..Any suggestion what is the
problem and how to solve such thing
ent... |
Python - multiple simultaneous threadpools
Question: I'm writing a web scraper in python, using httplib2 and lxml (yes - I know I
could be using scrapy. Let's move past that...) The scraper has about 15000
pages to parse into approximately 400,000 items. I've got the code to parse
the items to run instantaneously (almo... |
how to concatenate multiple files for stdin of Popen
Question: I'm porting a bash script to python 2.6, and want to replace some code:
cat $( ls -tr xyz_`date +%F`_*.log ) | filter args > bzip2
I guess I want something similar to the "Replacing shell pipe line" example at
<http://docs.python.org/re... |
carriage characters are lost in the resulted string when reading a file on windows
Question: When reading a txt file in windows by python, carriage characoters are lost in
resulted string.
c:/text.txt
aaa\r\nbbb\r\nccc\r\nddd
code:
input = open('c:/text.txt')
str = input.read()
... |
Python serial communication
Question: I'm working on an Arduino project, and I am interfacing it with a Python
script due to memory limitations. On the Python side I have a 2 dimensional
matrix containing respective x, y values for coordinates, and in this list is
26000 coordinate pairs. So, in interest of clarifying t... |
How to generically apply an override of a function to mutiple classes in python?
Question: I am working on a Django application but this seems like it is just a python
question, with nothing necessarily specific to Django. I'm pretty new to
python, and its hard to describe what I am trying to do, but easier to show so
... |
Array order in `numpy.dot`
Question: In Python's [numerical library NumPy](http://numpy.org/), how does the
`numpy.dot` function deal with arrays of different memory-order?
`numpy.dot(c-order, f-order)` vs. `dot(f-order, c-order)` etc.
The reason I ask is that long time ago (numpy 1.0.4?), I made some tests and
notice... |
JSON Encoding with Django adding extra \\ characters
Question: I'm trying to create a function that will convert a dictionary containing a
message and a Django model instance into JSON, that I can pass back to the
client. For example, I have the model Test defined in models.py.
from django.db import mode... |
Locate unused structures and structure-members
Question: Some time ago we took over the responsibility of a legacy code base.
One of the quirks of this very badly structured/written code was that it
contained a number of really huge structs, each containing hundreds of
members. One of the many steps that we did was to... |
Ignore ImportError when exec source code
Question: I have an application that reads test scripts in python and sends them across
the network for execution on a remote python instance. As the controlling
program does not need to run these scripts I do not want to have all the
modules the test scripts use installed on th... |
RegEx to delete all double whitespace EXCEPT \n? preg_replace
Question: I have imported a plain-text version of PDF using a Python script, but it has
a bunch of garbage artifacts that I just don't care about.
The only whitespace I care about is (1) **single** spaces, and (2) **double**
\n's.
**Single space,** for obv... |
Implementing a "Pythonic" map in Scheme: bad idea?
Question: In Scheme, the function `(map fn list0 [list1 .. listN])` comes with the
restriction that the lists must have the same number of elements. Coming from
Python, I'm missing the freedom of Python list comprehensions, which look a
lot like `map` above, but withou... |
Searching CSV Files (Python)
Question: I've made this CSV file up to play with.. From what I've been told before, I'm
pretty sure this CSV file is valid and can be used in this example.
Basically I have this CSV file 'book_list.csv':
name,author,year
Lord of the Rings: The Fellowship of the Ring... |
getting error with execute many in python
Question: I am learning python and i am new bie. I am trying to use functions with mysql
and python and i ma getting errors
This is my script
import MySQLdb
def insert_values(cursor, values):
#cursor = self.connection.cursor()
cursor.executem... |
Memory leak while looping web.client.getPage function
Question: I have a page what refresh periodically using this script:
from twisted.web.client import getPage
from twisted.internet import reactor, task
def getData():
dgp = getPage('http://www.google.com/')
dgp.addCallback(... |
import C++ module, if fail: import Python version?
Question: I have a Python pyd module written in C++. I also have a Python version of the
module (which is much slower). My question is, as I want the program to run on
multiple OSs, can I try to import the C++ version in the program and import
the slower Python version... |
Fix invalid XML with ampersands in Python
Question: I am using Python to manipulate an XML file I receive from another system.
That system produces invalid XML. Mainly, it doesn't escape some of the & in
the XML.
So, for example, I have some lines like that:
<IceCream>Ben&Jerry</IceCream>
Of c... |
Nothing except "None" returned for my Python web.py Facebook app when I turn on "OAuth 2.0 for Canvas"
Question: I am a beginning Facebook app developer, but I'm an experienced developer. I'm
using web.py as my web framework, and to make matters a bit worse, I'm new to
Python.
I'm running into an issue, where when I t... |
Are Mixin class __init__ functions not automatically called in python?
Question: I'd like to use a Mixin to always add some init functionality to my child
classes which each inherit from different API base classes. Specifically, I'd
like to make multiple different child classes that inherit from one of these
different ... |
invalid syntax in python while trying to plot
Question: After my blunder with the infinity factorial sum XD I redid the code, but I
keep getting syntax error :\
from scitools.std import *
from math import factorial, cos, e
from scipy import *
import numpy as np
def f1(t):
... |
Checking for interactive shell in a Python script
Question: I need to determine whether the shell which invoked my Python script was in
interactive mode or not. If it was in interactive mode, the program should
pipe output to less(1) for easy reading. If not, it should simply print its
output to stdout, to allow it to ... |
Python Shelve Module Memory Consumption
Question: I have been assigned the task of reading a .txt file which is a log of various
events and writing some of those events into a dictionary.
The problem is that the file can sometimes get bigger than 3GB in size. This
means that the dictionary gets too big to fit into mai... |
Django and architecture : how to share a "referencial" database between projects?
Question: I come today with a design/architecture question concerning Django.
I work on several websites (hosted on the same server) which individually need
geographical data (states, towns, etc.). Each project contains apps, and each
ap... |
How to send a value from Arduino to Python and then use that value
Question: I am in the process of building a robot that is remote controlled using Python
to send control messages via the Internet through a simple GUI.
I have gotten part of my code working pretty well, the GUI and control
systems, but I am stuck. I a... |
How to save an Image using URL in python/django
Question: If you were to save an Image using it's URL how would you do it ?
Also how do I give the Image a unique file name while saving it.
response = urllib.urlopen(image_url)
file_name = ''.join(random.choice(string.ascii_uppercase + string.... |
Sql statement with like from variable
Question: I'm executing this code in python
from sqlite3 import dbapi2 as sqlite
con = sqlite.connect("db.sqlite")
cur = con.cursor()
surname = "'%atton%'"
cur.execute("select id from singers where surname like :surname", locals())
cur.close(... |
File locks in SQLite
Question: I'm writing my first SQLAlchemy (0.6.8)/Python (2.7.1) program, sitting on top
of SQLite (3.7.6.3, I think), running on Windows Vista.
In order to perform unit-testing, I am pointing SQLite to a test database, and
my unit-test scripts routinely delete the database file, so I am continuou... |
Why pass string that represents an object instead passing the object?
Question: Code below is from `Django`'s `settings.py`. Since everything in `Python` is
an object, why don't just pass installed apps as tuple of objects:
INSTALLED_APPS = (
django.contrib.auth,
django.contrib.contenttypes,
... |
In Python, how can I detect whether the computer is on battery power?
Question: I'm playing around with pygame, and one thing I'd like to do is reduce the
number of frames per second when the computer is on battery power (to lower
the CPU usage and extend battery life).
How can I detect, from Python, whether the compu... |
Correct way to write line to file in Python
Question: I'm used to doing `print >>f, "hi there"`
However, it seems that `print >>` is getting deprecated. What is the
recommended way to do the line above?
**Update** : Regarding all those answers with `"\n"`...is this universal or
Unix-specific? IE, should I be doing `"... |
help with python ctypes and nvapi
Question: My end goal is to query NVAPI for gpu usage and other statistics in python.
See <http://developer.nvidia.com/nvapi>
from ctypes import WinDLL
nvapi = WinDLL("nvapi.dll")
print nvapi# <WinDLL 'nvapi.dll', handle 718a0000 at 27c0050>
print nvapi.nvapi... |
Building Python and more on missing modules
Question: I have another thread asking help on "missing zlib". With the nice help the
problem has been resolved (almost).
Now I am interested in building Python myself (on Ubuntu 10.10).
A few important questions have caught my attention:
1. After building Python (say 2.... |
Reraise HTTPError with extra info
Question: I want to catch a `urllib2.HTTPError` with extra information if it's a 404:
try:
data = urlopen(url)
except HTTPError, e: # Python 2.5 syntax
if e.code == 404:
raise HTTPError('data not found on remote')
else:
... |
Writing RDF/XML file from rdf Triples in rdflib
Question: I have got rdf triples with me, now I am interested in generating RDF/XML file
using rdflib in Python. Could you please give me some sample code to start.
Thanks
Answer: The [rdflib docs](https://rdflib.readthedocs.org) could be a good starting
point, particu... |
How to make a ssh connection with python?
Question: Can anyone recommend something for making a ssh connection in python? I need
it to be compatible with any OS.
I've already tried pyssh only to get an error with SIGCHLD, which I've read is
because Windows lacks this. I've tried getting paramiko to work, but I've had
... |
Parallel computing with Python
Question: here is the code of my python script:
import time
for j in range(1,150,1):
for i in range(1,5,1):
x = j + i
print(x)
time.sleep(180)
This script is started out of my Finite Element programm... |
Using Python and Beautifulsoup how do I select the desired table in a div?
Question: I would like to be able to select the table containing the "Accounts Payable"
text but I'm not getting anywhere with what I'm trying and I'm pretty much
guessing using findall. Can someone show me how I would do this?
For example this... |
Python: Implementing a series of functions with each one calling the next
Question: programming isn't my field, but I'm trying to learn. I've been writing a
program that works something like this:
from Tkinter import *
root=Tk()
def Secondwindow():
firstframe.destroy()
second... |
PySerial API thinks the com port is still open during a write(), why?
Question: I am using PySerial (a Python API for serial communication) to send AT
commands to a Nokia phone via bluetooth.
import serial
com = serial.Serial()
com.port = 19
com.timeout = 0 #also tried a timeout value greater... |
Starting a subprocess via python multiprocessing hangs
Question: I'm using pyAudio to listen to the audio device and do some "stuff" in the
background while the main program continues to run.
I started out with a second script, but would like to consolidate into a
single script for supportability. When I moved the fun... |
Is there a meaningful way to use context managers inside generators?
Question:
from contextlib import contextmanager
@contextmanager
def context():
print "entering"
yield
print "exiting"
def test():
with context():
for x in range(10):
... |
GAE: managing dev and production versions of my app
Question: There are a lot of things I need to do before uploading my production app to
GAE. Its becoming very tedious and error-prone, and I would like to know some
best-practice how to handle following requirements, and if some tools already
exist for doing this:
De... |
In a unit test, how can the parameter passed to a custom exception be determined?
Question:
class AppError(Exception): pass
class MissingInputError(AppError):
em = {1101: "Date input is missing. Please verify.", \
1102: "Key input is missing. Please verify.", \
110... |
Getting a number of digits
Question: I've been searching for a way in python to get only 4 digits on the right of
the comma of a decimal number, but i couldn't find. Took a look on this
post,---> [Rounding Decimals with New Python Format
Function](http://stackoverflow.com/questions/1598579/rounding-decimals-with-
new-p... |
Import strings from .txt and searching for first numeric character - python
Question: I am a total noob with python (programming in fact) but I hope you can help :)
I have a .txt file with a list of strings containing addresses.
I want to import it to Python and then search for the first numberic character
and then c... |
Python - how can I read stdin from shell, and send stdout to shell and file
Question: I'd like to have a Python script read stdin from the shell (bash), and send
stdout to shell as well a redirected file. I tried the following:
$ cat test.py
#!/usr/bin/python
val = raw_input("enter val: ")
... |
fast parsing links out of a page in python
Question: I need to parse a large number of pages (say 1000) and replace the links with
tinyurl links.
right now i am doing this using a regex
href_link_re = re.compile(r"<a[^>]+?href\s*=\s*(\"|')(.*?)\1[^>]*>", re.S)
but its not fast enough.
i am thinki... |
Problem posting to datastore with deferred.defer tasks
Question: I am trying to do this on Google App Engine in Python:
def add_to_db(person):
a = PersonDb(key_name = person)
# get some data
data1 = a.name
data2 = a.age
a.put()
for person in people:
... |
Detect re (regexp) object in Python
Question: I wonder what is the proper pythonic backward- and forward-compatible method
how check if an object is compiled `re` object.
`isinstance` method cannot be easily used, while the resulting object claims
to be `_sre.SRE_Pattern` object:
>>> import re
>>> r... |
Performing many means in numpy
Question: Good Morning, I am implimenting a Cressman filter for doing distance weighted
averages in Numpy.. I use a Ball Tree implimentation (thanks to Jake
VanderPlas) to return a list of locatations for each point in a request
array.. the query array (q) is shape [n,3] and at each point... |
Reading lines from text file in python (windows)
Question: I am working on a simple import routine that translates a text file to a json
file format for our system in python.
import json
# Open text file for reading
txtFile = open('Boating.Make.txt', 'r')
# Create picklist obj
p... |
activemq how to configure to work with stomp in python
Question: I have activemq installed and running locally, but when I run the following
script, I get an error:
#!/usr/bin/env python
import time
import sys
import stomp
class MyListener(object):
def on_error(self, hea... |
Multivariate spline interpolation in python/scipy?
Question: Is there a library module or other straightforward way to implement
multivariate spline interpolation in python?
Specifically, I have a set of scalar data on a regularly-spaced three-
dimensional grid which I need to interpolate at a small number of points
s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.