text stringlengths 226 34.5k |
|---|
How can I can I programatically post a note to Google Reader?
Question: I use my Google Reader notes as a place to store bookmarks and small snippets
of information. I would like to write a small script to let me post notes from
the command line (I prefer Python,but an answer using any language will be
accepted).
[Thi... |
How can I see the details of an exception in Python's debugger?
Question: Sometimes while I'm debugging an exception will be raised.
For example, consider this code:
def some_function(): # Pretend this function is in a library...
# ...and deep within the library is an exception:
raise E... |
How to spread django unit tests over multiple files?
Question: * I have a python-django application
* I'm using the [unit testing framework](https://docs.djangoproject.com/en/1.3/topics/testing/)
* The tests are arranged in the file "tests.py" in the module directory
* I'm running the tests via `./manage.py tes... |
md5 a string multiple times get different result on different platform
Question: t.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/md5.h>
static char* unsigned_to_signed_char(const unsigned char* in , int len) {
char* res = (char*)malloc(len * 2 +... |
Run custom admin command from view
Question: I have a custom admin command that emails out reports. It normally runs from a
cron job. What I would like to do is add a button to my web app that when
clicked will cause the the admin command to run there and then rather than
wait for the cron job to call it. How do I do t... |
python & suds "ImportError: cannot import name getLogger"
Question: I'm using Ubuntu 11.04 (natty). I have been using Suds to consume a SOAP web
service. Everything was working fine... until it wasn't. I can no longer
import Suds. I've uninstalled and re-installed Suds from the Ubuntu
repositories but still get the sam... |
Python: thinking of a module and its variables as a singleton — Clean approach?
Question: I'd like to implement some sort of singleton pattern in my Python program. I
was thinking of doing it without using classes; that is, I'd like to put all
the singleton-related functions and variables within a module and consider i... |
Python WebKitWebView: how to get (generated) source code
Question: Is it possible to get the generated source code (so including JavaScript added
DOM nodes) with Python and WebKit, and if so, how?
import webkit
web_view = webkit.WebView()
web_view.open('http://google.com')
But then?
Answe... |
Will this eventually lead to a crash (wxpython)
Question: I have over 300 questions/prompts that I plan to include in the program. The
flow is pretty much like this:
**Create a window with the question. Store answer in variable. Create NEW
window with question. Store NEW answer.**
_this continues on for over 300 ques... |
Turbomail Integration with Pyramid
Question: I am in need of a method to send an email from a Pyramid application. I know
of
[pyramid_mailer](http://docs.pylonsproject.org/projects/pyramid_mailer/en/latest/),
but it seems to have a fairly limited message class. I don't understand if
it's possible to write the messages ... |
Is it bad style to reassign long variables as a local abbreviation?
Question: I prefer to use long identifiers to keep my code semantically clear, but in
the case of repeated references to the same identifier, I'd like for it to
"get out of the way" in the current scope. Take this example in Python:
def ... |
python bitarray to and from file
Question: I'm writing a large bitarray to a file using this code:
import bitarray
bits = bitarray.bitarray(bin='0000011111') #just an example
with open('somefile.bin', 'wb') as fh:
bits.tofile(fh)
However, when i attempt to read this data back u... |
How do I use timesince
Question: I found this snippet:
def timesince(dt, default="just now"):
now = datetime.utcnow()
diff = now - dt
periods = (
(diff.days / 365, "year", "years"),
(diff.days / 30, "month", "months"),
(diff.... |
Write unicode content and unicode file name in Windows
Question:
#source file is encoded in utf8
import urllib2
import re
req = urllib2.urlopen('http://people.w3.org/rishida/scripts/samples/hungarian.html')
c = req.read()#.decode('utf-8')
p = r'title="This is Latin script \(Hungarian ... |
Optimization of SPARQL query. [ Estimated execution time exceeds the limit of 1500 (sec) ]
Question: I am trying to run this query on <http://dbpedia.org/sparql> but I get an
error that my query is too expensive. When I run the query trough
<http://dbpedia.org/snorql/> I get:
The estimated execution time... |
Opening the Excel application from Python
Question: I am using 'xlwt' to write into Excel files as part of my project in Python. I
also need to actually open the Excel spreadsheet for display and also close
it. I found a function:
import webbrowser
webbrowser.open('C:/Users/300231823/Desktop/GUI/simp... |
best method and data structure for sorting a list of tuples into multiple lists?
Question: Let's say I have a list of tuples like this:
l = [('music','300','url'),('movie','400','url'),
('clothing','250','url'),('music','350','url'),
('music','400','url'),('movie','1000','url')]
and that I ... |
problems with python-mailer and google?
Question: I've just tried the following:
server = smtplib.SMTP(smtpname, smtpport)
server.ehlo()
server.starttls()
server.ehlo()
server.login(username, password)
server.sendmail(username, recipient, "TEST")
server.close()
smtpname is "... |
date2num , ValueError: ordinal must be >= 1
Question: I'm using the matplotlib candlestick module which requires the time to be
passed as a float day format . I`m using date2num to convert it, before :
This is my code :
import csv
import sys
import math
import numpy as np
import datetime... |
Get specifics elements of a xml output in python
Question: I'm getting some problems to get this part of the code, that I get from
[yourself](http://stackoverflow.com/questions/1140672/parsing-
xml/1140753#1140753). Here is my code:
import cStringIO
import pycurl
from xml.etree import ElementTree... |
Save an array as bin in Matlab, pass it to Python and read the bin file in Python
Question: I am currently trying to save an array as bin file in Matlab, send it to
Python and read it in Python. However, Matlab is showing errors when I run it.
I am using the following codes:
Read the array in Matlab, convert to bin fi... |
How to solve AttributeError when importing igraph?
Question: When I import the igraph package in my project, I get an AttributeError. This
only happens in the project directory:
[12:34][~]$ python2
Python 2.7.1 (r271:86832, Apr 15 2011, 12:09:10)
[GCC 4.5.2 20110127 (prerelease)] on linux2
T... |
Python: no module named unittest. How can I fix this?
Question: It seems strange that a module from the std Python lib to be missing. I'm
probably doing something wrong, but I cannot figure out what exactly.
shift@bt:~/experiments/$ python test/test_creation.py
'import site' failed; use -v for trace... |
urllib2 gives HTTP Error 400: Bad Request for certain urls, works for others
Question: I'm trying to do a simple HTTP get request with Python's urllib2 module. It
works sometimes, but other times I get `HTTP Error 400: Bad Request`. I know
it's not an issue with the URL, because if I use `urllib` and simply do
`urllib.... |
question about IDLE debugger in Python
Question: This is a simple question, is it possible to view an entire list in the locals
box of the IDLE debugger? Because right now, if a list becomes too long, the
debugger will put an ellipsis and not show the entire list. I also tried
typing in the name of the list in the actu... |
Sibling package imports
Question: I've tried reading through questions about sibling imports and even the
[package documentation](http://docs.python.org/tutorial/modules.html#intra-
package-references), but I've yet to find an answer.
With the following structure:
├── LICENSE.md
├── README.md
├─... |
Python: Matplotlib - probability plot for several data set
Question: I have several data sets (distribution) as follows:
set1 = [1,2,3,4,5]
set2 = [3,4,5,6,7]
set3 = [1,3,4,5,8]
How do I plot a scatter plot with the data sets above with the y-axis being
the probability (i.e. the percentile ... |
Python- Possible English one-word anagrams given input letters
Question: I know variations of this have been asked before, but I was unable to
understand any of the previous implementations because most of them involved
using sets and the issubset method.
Here is what I am trying to do: I have a set of words in a dict... |
how to get the math operators strings from module `operator` in python
Question: Take `operator.add` for example:
>>>import operator as op
>>>op.add(1,2) #means 1 + 2
3
>>>op.add.__name__
'add'
I want sort of:
>>>op.add.math_str
"+"
Can I get all those... |
How to compare two lists of dicts in Python?
Question: How do I compare two lists of `dict`? The result should be the odd ones out
from the list of dict B.
Example:
ldA = [{'user':"nameA", 'a':7.6, 'b':100.0, 'c':45.5, 'd':48.9},
{'user':"nameB", 'a':46.7, 'b':67.3, 'c':0.0, 'd':5.5}]
... |
small language in python
Question: I'm writing what might not even be called a language in python. I currently
have several operators: `+`, `-`, `*`, `^`, `fac`, `@`, `!!`. `fac` computes a
factorial, `@` returns the value of a variable, `!!` sets a variable. The code
is below. How would I go about writing a way to def... |
pyparsing issue
Question: Right now I have just started to use `pyparsing` to parse simple postfix
expressions. At the moment, I got this far:
from pyparsing import *
integer = Word(nums)
op = Word("+-*/^", max=1)
space = Word(" ")
expr = Word(nums)+space+Word(nums)+space+op
parsed = ... |
Importing a long list of constants to a Python file
Question: In Python, is there an analogue of the `C` preprocessor statement such as?:
`#define MY_CONSTANT 50`
Also, I have a large list of constants I'd like to import to several classes.
Is there an analogue of declaring the constants as a long sequence of
stateme... |
sharing variables between powershell and C#
Question: I am trying to build a document assembly application in .Net that will allow
rules and conditions to be embedded within the document fragments, presumably
using some kind of scripting language (and I don't really want to invent my
own scripting language)
I need the... |
What's the best way to initialise and use contants across Python classes?
Question: Here's how I am declaring constants and using them across different Python
classes:
# project/constants.py
GOOD = 1
BAD = 2
AWFUL = 3
# project/question.py
from constants import AWFUL, BAD, GOOD
... |
Keeping a pipe to a process open
Question: I have an `app` that reads in stuff from `stdin` and returns, after a newline,
results to `stdout`
A simple (stupid) example:
$ app
Expand[(x+1)^2]<CR>
x^2 + 2*x + 1
100 - 4<CR>
96
Opening and closing the `app` requires a lot of initializa... |
using pipe with python
Question:
import re
import subprocess
sub = subprocess.Popen(['/home/karthik/Downloads/stanford-parser-2011-06- 08/lexparser.csh'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr = subprocess.PIPE)
sub.stdin.write("i am a fan of ac milan which is the best club ... |
How do I run some python code in another process?
Question: I want to start, from Python, some other Python code, preferably a function,
but in **another process**.
It is mandatory to run this in another process, because I want to run some
concurrency tests, like opening a file that was opened exclusively by the
paren... |
Forward-compatible print statement in python 2.5
Question: OK, maybe I'm just having an off day. This seems like something a lot of
people must be asking, but Google is failing me horribly. The closest thing I
found was [this](http://stackoverflow.com/questions/388069/python-graceful-
future-feature-future-import) whic... |
counting (large number of) strings within (very large) text
Question: I've seen a couple variations of the "efficiently search for strings within
file(s)" question on Stackoverflow but not quite like my situation.
* I've got one text file which contains a relatively large number (>300K) of strings. The vast majority... |
python version of C unsigned char
Question: I need help with a python version for this C code:
#define HostBusy_high 0x02
#define control_register 0x37a
Out32 (control_register,(unsigned char)(Inp32(control_register) | HostBusy_high));
the Out32 and Inp32 are functions located in ... |
Help verifying RSA signed text with Python
Question: Using Java I have created RSA keypairs. Using Java I can use these keys to
sign and verify some text. I can also "export" these keys in PEM format and
load them into a Python test script. Once in the Python script, I can use
these keys to sign and verify some text us... |
Wrapping C++ classes that contain wxString with Cython
Question: I'm working on a Python extension to tie in with a C++ application written
using wxWidgets for the GUI. I'm using Cython, and have the basic system
(build tools, plus a starter extension with appropriate version details etc)
happily working.
I'm only int... |
Unknown screen output of manually installed Python 2.7
Question: I installed Python 2.7 today using:
./configure --prefix=/home/zhanwu/local --enable-shared --enable-profiling --with-pydebug
make install
Then I keep getting something like "[37745 refs]" on screen after each
function call:
... |
How to insert DTD DOCTYPE content when using SAX to generate XML output in Python
Question: I am trying to generate a large XML file using python(actually jython)
xml.sax.saxutils.XMLGenerator. I would like to include DTD information but I
could not figure out how to pass the DTD string to SAX. Here is the sample SAX
w... |
Xml parsing with Python using recursion. Problem with return value
Question: I am somewhat new to Python and programming in general so I apologize. By the
way, thanks in advance.
I am parsing an xml document (kml specifically which is used in Google Earth)
using Python 2.5, cElementTree and expat. I am trying to pull ... |
Adding context menu option through Python
Question: I'm trying to make a small Python script that is executed by clicking an
option in a file's context menu. It would execute something like
"path_to_script %L", where %L is (I think) the location of the file the user
has right-clicked. I know I have to add something to ... |
Iron Python - No module named "os"
Question: I have been trying to debug this sample code, but I am having trouble.
**Here is the code:**
import System
import get_events_devices
from System.Windows.Forms import *
from System.ComponentModel import *
from System.Drawing import *
from c... |
Python mysqldb: Library not loaded: libmysqlclient.18.dylib
Question: I just compiled and installed mysqldb for python 2.7 on my mac os 10.6. I
created a simple test file that imports
import MySQLdb as mysql
Firstly, this command is red underlined and the info tells me "Unresolved
import". Then I t... |
Problem with creating an object in neo4j
Question: I am using the django integration for neo4j and I'm getting the following
traceback when I'm trying to create a node.
I do have JPype installed and it can be imported.
p = Person.objects.create(first_name='omer', last_name='katz')
Traceback (most ... |
Quick and easy: trayicon with python?
Question: I'd just need a quick example on how to easily put an icon with python on my
systray. This means: I run the program, no window shows up, just a tray icon
(I've got a png file) shows up in the systray and when I right-click on it a
menu appears with some options (and when ... |
Pydev: Where do I have to add the path for an external lib (usr/local/mysql/lib/libmysqlclient)?
Question: I use mysqldb and pydev eclipse. I successfully compiled mysqldb 1.23 and now
I would like to import it. mysqldb 1.23 needs the library
libmysqlclient.18.dylib which lies in my case in /usr/local/mysql/lib. So whe... |
Split PDF files in python - ValueError: invalid literal for int() with base 10: '' "
Question: I am trying to split a huge pdf file into several small pdfs usinf pyPdf. I
was trying with this oversimplified code:
from pyPdf import PdfFileWriter, PdfFileReader
inputpdf = PdfFileReader(file("document.... |
Very basic Python question (strings, formats and escapes)
Question: I am starting to learn Python with an online guide, and I just did an exercise
that required me to write this script:
from sys import argv
script, filename = argv
print "We're going to erase %r." % filename
print "I... |
Python SocketServer.TCPServer request
Question: I've been playing around with Python's SocketServer:
#!/usr/bin/python
import SocketServer
class EchoHandler(SocketServer.BaseRequestHandler):
def handle(self):
data=self.request.recv(1024)
self.request.send... |
Something wrong with wtforms FieldList && validation
Question: Something wrong with wtforms FieldList && validation... It should say that
field must have Int value, not This field is required Why f.data has [None, 2,
None] value, not ['def', 2, 'abc'] ?
from webob.multidict import MultiDict
from... |
Google app engine(python) ImportError: No module named oauth2 in google app engine
Question: I have used python twitter script from <http://code.google.com/p/python-
twitter/> and oauth2 from <https://github.com/simplegeo/python-oauth2>
Answer: To import third-party modules in App Engine, they need to be included (or... |
Django.db import error
Question:
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/django/db/__init__.py", line 14, in <module>
if not settings.DATABASES:
File "/usr/local/lib/python2.6/dist-packages/django/utils/functional.py", line 276, in __getattr__
se... |
Python exception ordering
Question: Just curious, why does the following code
import sys
class F(Exception):
sys.stderr.write('Inside exception\n')
sys.stderr.flush()
pass
sys.stderr.write('Before Exception\n')
sys.stderr.flush()
try:
raise F
... |
Python query: iterating through log file
Question: Please can someone help me solve the following query? I have a log file with
thousands of lines like the following:-
jarid: 7e5ae720-9151-11e0-eff2-00238bce4216 recv: 1 timestamp: 00:00:02,217
jarid: 7e5ae720-9151-11e0-eff2-00238bce4216 ack: ... |
Any way of getting PyDoc into Jira Confluence
Question: I'm using PyDoc to generate documentation from my Python code and I'm using
Jira's Confluence plugin to manage documentation. Is there any way to
generating PyDoc documentation and putting it into Confluence?
Googling didn't yield too many results.
Thanks everyo... |
Error while trying to setup a Jython interpreter
Question: I wanted to boot up a Jython interpreter inside the plugin, then execute files
inside the interpreter.
package com.jakob.jython;
import org.bukkit.plugin.java.JavaPlugin;
import org.python.core.PyObject;
import org.python.util.Py... |
Python HTTPConnection file send with httplib, retrieving progress
Question: In a django app I'm using a third-party Python
[script](http://wiki.blip.tv/index.php/REST_Upload_Python_Script) to allow
users to upload files to blip.tv through httplib.HTTPConnection.send on an EC2
instance. Since these files are generally l... |
events created with python vobject are not recognised by ms exchange
Question: I create an meeting invite using the python vobject and django's
`EmailMultiAlternatives` as follows:
cal = vobject.iCalendar()
cal.add('method').value = 'REQUEST' #IE/Outlook needs this
vevent = cal.add('vevent')
... |
How to include autocomplete in a python web form with MongoDB
Question: I wrote a web page in Python as follows:
#!/usr/bin/env python
import os, re, sys
from datetime import datetime
from pymongo import Connection
import cgi
class Handler:
def do(self, environ... |
jdbc: Get the SQL Type Name from java.sql.Type code
Question: I have an array with Field Names and jdbc Type codes. (Those int codes that
you can find in
<http://download.oracle.com/javase/1.4.2/docs/api/constant-
values.html#java.sql.Types.BIT>
I use a level 4 Driver.
I can't figure out how to ask the driver for th... |
mod_wsgi python2.5 ubuntu 11.04 problem
Question: I have such cfg on my amd64 platform with ubuntu 11.04:
1. build python2.5 from source to /usr/local/python2.5
2. virtualenv at /home/se7en/.virtualenvs/e-py25
alsp i recompile mod_wsgi.so to custom python:
se7en@se7en-System-Product-Name:~$ ldd /us... |
Help with solving the DistributionNotFound error in Virtualenv
Question: I've installed `virtualenv` on my system which the argument to not copy over
any site packages. Then I did an `easy_install` to install Django and that
went fine too.
In the virtual environ when i try and try `django-admin.py`, I get an error
tha... |
pygame freezes when I try to exit it after running it from IDLE!
Question: I'm running it through the livewires wrapper which is just training wheels for
pygame and other python modules in general; but everytime I run it, it'll
execute and when I try to exit, it will not respond and then crash.
Any input on how I coul... |
No module named os found -- Django, mod_wsgi, Apache 2.2
Question: I'm trying to set up apache, mod_wsgi, and django. I'm getting an internal
server error with this in my apache error log:
[Wed Jun 22 21:31:55 2011] [error] [client ::1] mod_wsgi (pid=2893): Target WSGI script '/django/internal/django-dev... |
soaplib with mod_wsgi without django, cherypy or other framework
Question: I checked soaplib for python on net and i get the example
import soaplib
from soaplib.core.service import rpc, DefinitionBase
from soaplib.core.model.primitive import String, Integer
from soaplib.core.server import wsg... |
Where does python look for a dll opened by ctypes.cdll.<name> on windows?
Question: I'm afriad I couldn't find a simple answer for this on the internet, so maybe
there will be one in the future because of this question!
I'm using pywiiuse, a python wrapper for the C wiiuse library on windows. I've
gotten several plain... |
trying to rotate a triangle with complex numbers in tkinter python
Question: the first method is mine, the other two are from here
<http://effbot.org/zone/tkinter-complex-canvas.htm>
so i call the rotate method that calls the second one that calls the first
one. the first one gets the xy coordinates from the angle tha... |
unpickling python 2.6 object in python 3.1.1
Question: In python 2.6, I defined a class Abc, made a dict d where keys are strings and
values are abc objects. Then I dumped this dict to a file like this-
pickle.dump(d, open('filename.pkl', 'wb'))
I can successfully load it python 2.6 with
d1 = pickle.loa... |
python Decimal precision
Question: For some reason Decimal object looses precision when multiplied. There is no
reason to happen so. Please check the testcase and enlighten me.
from decimal import *
getcontext().prec = 11
a = Decimal('5085.28725881485')
b = 1
print getcontext()
... |
How to sign a string under iOS using encrypted key?
Question: I have keys created in Java. The private key is PKCS#8 encrypted, in PEM
string.
Here is an example of using the private key with M2Crypto in Python:
from M2Crypto import EVP, BIO
privpem = "-----BEGIN ENCRYPTED PRIVATE KEY-----\nMIICoTAb... |
Python Strategy pattern: Dynamically import class files
Question: I am trying to build a software package that fixes arbitrary data
inconsistencies in one of my databases. My design includes two classes -
`Problem` and `Fix`.
The problems are SQL queries stored as `.cfg` files (e.g. `problem_001.cfg`),
and the fixers ... |
python matplotlib colorbar setting tick formator/locator changes tick labels
Question: users, I want to customize the ticks on a colorbar. However, I found the
following strange behavior. I try to change the tick formator to the default
formator (I thought this should change nothing at all) but I end up with
different ... |
Numpy Array to base64 and back to Numpy Array - Python
Question: I am now trying to figure out how I can recover a numpy array from base64
data. This question and answer suggest it is possible: [Reading numpy arrays
outside of Python](http://stackoverflow.com/questions/2725602/reading-numpy-
arrays-outside-of-python) b... |
About insert shell commands into python
Question: I've inserted some shell commands into python script like below:
#!/usr/bin/python
import os,sys,re
import gzip
import commands
path = "/home/x/nearline"
for file in os.listdir(path):
if re.match('.*\.recal.fastq.g... |
Synthesize musical notes (with piano sounds) in Python
Question: I would like to have a python implementation of a musical instrument library
(for instance, a piano object) that I can use to convert a list of notes and a
duration into sound. For instance, something like:
import Piano
pn = Piano(... |
python urllib2 question
Question: I am trying to print some info from an url, but I want to skip the print if a
certain text if found, I have:
import urllib2
url_number = 1
url_number_str = number
a = 1
while a != 10:
f = urllib2.urlopen('http://example.com/?=' + str(url... |
Why am I getting "Exception: (404, u'Not Found')" with Suds
Question: I am trying to connect to SugarCRM soap services (what's the correct
terminology?) using Suds:
from suds.client import Client
url = "http://localhost/sugarcrm/soap.php?wsdl"
client = Client(url)
session = client.servic... |
Python: binary file to gz file and then to jpg extension and finally return again to the original binary file
Question: I want to do the following in Python:
1. Take a binary (executable) file
2. Turn it into a zip file with gzip (gz extension)
3. Then put the jpg extension
Later again the desire to recover the... |
Accept a range of numbers in the form of 0-5 using Python's argparse?
Question: Using argparse, is there a way to accept a range of numbers and convert them
into a list?
For example:
python example.py --range 0-5
Is there some way input a command line argument in that form and end up with:
... |
GUI interface for sqlite data entry in Python
Question: I am making a simple sqlite database for storing some non-sensitive client
information. I am very familiar with python+sqlite and would prefer to stick
with this combo on this project. I would like to create an simple GUI
interface for data entry and searching of ... |
Tornado's AsyncHTTPClient no longer works after upgrade to 2.0 from 1.2
Question: Decided I'd kick the tires of Tornado 2.0 tonight, but it appears to have done
a number on ASyncHTTPClient for me. Nothing in the release notes for 2.0
indicates any real changes are necessary to how I'm using ASyncHTTPClient:
**[EDIT: m... |
Need more efficient way to parse out csv file in Python
Question: Here's a sample csv file
id, serial_no
2, 500
2, 501
2, 502
3, 600
3, 601
This is the output I'm looking for (list of serial_no withing a list of ids):
[2, [500,501,502]]
[3, [600, 601]]
I... |
Looping in Python and keeping current line after sub routine
Question: I've been trying to nut out an issue when looping in python 3. When returning
from sub routine the "line" variable has not incremented.
How do I get the script to return the latest readline from the subsroutine?
Code below
def getDa... |
Class referencing Error - sometimes an issue
Question: Okay so I did not know what to search for in order to answer this question.
In my code for some reason some of my classes can be referenced as per
instructions by Python
class MyClass:
"""A simple example class"""
i = 12345
d... |
Why the Segmentation Fault! When I attempt to run / use Python Package gensim?
Question: Am attempting to use `[gensim][1]`, a Vector Space Modelling package for
python in some Machine Learning experiments of mine. I followed their
installation instructions as said
[here](http://nlp.fi.muni.cz/projekty/gensim/install.h... |
Obtaining loaded images from a given URL via Python
Question: Is there anyway to load a URL via Python and then retrieve a list of all of
the images that were loaded via that URL? I'm essentially looking to do
something similar to TamperData or Fiddler and retrieve a list of all images
that a given website loaded.
An... |
Debugging a simple pygame game
Question: When I run this, it executes to an error in one of the imports. I posted the
error at tend end of the code. The program essentially doesn't run, I can't
tell what errors are occurring from the tracebacks. Any insight would be
appreciated.
from livewires import gam... |
Python Regular Expressions to extract date
Question: I have strings that look like these:
{server}_{date:YYYYMMDD}{int:######}
{server}_{date:MON DAY YYYY}{int:######}
...plus more, in different date formats. Also, there can be any number of {}
blocks, and they can appear in any order.
I'm try... |
How to delete a s3 version from a bucket using boto and python
Question: When I try to delete a bucket using the lines:
conn = boto.connect_s3(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
print conn.delete_Bucket('BucketNameHere').message
It tells me the bucket I tried to delete is not empty.... |
Why does printing to a utf-8 file fail?
Question: So I ran into a problem this afternoon, I was able to solve it, but I don't
quite understand why it worked.
this is related to a problem I had the other week: [python check if utf-8
string is uppercase.](http://stackoverflow.com/questions/6391442/python-check-
if-utf-8... |
how to encode url in python
Question: I have created a function for decoding url.
from urllib import unquote
def unquote_u(source):
result = source
if '%u' in result:
result = result.replace('%u','\\u').decode('unicode_escape')
result = unquote(result)
print resul... |
Why does Python's itertools.permutations contain duplicates? (When the original list has duplicates)
Question: It is universally agreed that a list of n _distinct_ symbols has n!
permutations. However, when the symbols are not distinct, the most common
convention, in mathematics and elsewhere, seems to be to count only... |
Python json memory bloat
Question:
import json
import time
from itertools import count
def keygen(size):
for i in count(1):
s = str(i)
yield '0' * (size - len(s)) + str(s)
def jsontest(num):
keys = keygen(20)
kvjson = json.dumps(dict((keys.n... |
Is there a more "Pythonic" way to combine CSV elements?
Question: Basically I am using a python cron to read data from the web and place it in a
CSV list in the form of:
.....
###1309482902.37
entry1,36,257.21,16.15,16.168
entry2,4,103.97,16.36,16.499
entry3,2,114.83,16.1,16.3
entry4,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.