text stringlengths 226 34.5k |
|---|
SQLAlchemy double-quoting LIKE filter
Question: For some reason, SQLAlchemy is double-quoting the LIKE filter value of my
queries!
The code is this:
query = app.db.session.query(model.Attribute)\
.filter(model.Attribute.name == 'photo0')\
.filter(model.Attribute.value.like('%' + file + '%... |
Making a Python program handle mailto links
Question: I actually found the answer to this before I asked the question, but I'm
posting it (and the answer, in an answer) for the sake of others who might
want to know (though if you have more insights, feel free to mention them).
EDIT: Someone else gave a better answer (s... |
Describing gaps in a time series pandas
Question: I'm trying to write a function that takes a continuous time series and returns
a data structure which describes any missing gaps in the data (e.g. a DF with
columns 'start' and 'end'). It seems like a fairly common issue for time
series, but despite messing around with ... |
syncdb fails with django-compositekey
Question: I'm planning to use django-compositekey to connect to a legacy db that makes
use of compound keys. Just to see that everything is working, I created a new
Django project with a simple model like this.
from django.db import models
from compositekey impor... |
Timer method inside a class
Question: First of all an introduction to my development environment:
OS: Windows.
SDK: Microsoft Visual Studio 2008.
Earlier today I was facing the problem of trying to define a Timer inside a
class. My class is interfacing a Python embedded module and a C++ backend... |
Using fields defined in constructor - Python
Question: I have a class as below that I'm using to connect to a remote SQL server
instance from a linux server python web app. I define and set cursor in the
**init** constructor and wish to use it throughout the class. How do I do
this? I come form a java background and do... |
Python: calculating checksum of a file for a weird protocol
Question: I'm having troubles calculating something like a checksum of a file for a
weird protocol that I'm trying to port to python.
The checksum is a 4 byte unsigned integer that is the result of adding all the
4-bytes unsigned integers of a file. For examp... |
Sending hex-data via socket, is interpreted as string
Question: I'm new to python, and I'm trying to use a 3rd party library/module. What I'm
doing now is:
s.send(rtp.header_bytes + rtp.payload)
# -> \x80!\x00\x01\x00\x00\x00d\x00\x00\x00\x00Testy
to send the header and the payload of a packet... |
Completely disable scrollbars on GTK webkit webview?
Question: I want a simple webview based on webkit, with a fixed size (e.g. 200x200) and
without any scrollbars. I use X with no window manager.
I tried the following Python code:
import gtk
import webkit
view = webkit.WebView()
... |
Python: Absorbing newlines on keyboard input
Question: I have a question specific to multi-line input from the keyboard. It appears
that my program is not absorbing newlines. The effect is that, after the input
is processed, the program appears to believe that there are a number of
carriage returns pending equal to the... |
Retreive the unique keys (second dimension) of a 2 dimensional dictionary in python?
Question: I have a a 2d dictionary (named d2_dic). I know how to get the unique keys
(It's always unique) of the first dimension by d2_dic.keys(). But how do I get
the unique keys of the second dimension?
from collection... |
Getting a file from an authenticated site (with python urllib, urllib2)
Question: I'm trying to get a queried-excel file from a site. When I enter the direct
link, it will lead to a login page and once I've entered my username and
password, it will proceed to download the excel file automatically. I am
trying to avoid ... |
How can I call Vim from Python?
Question: I would like a Python script to prompt me for a string, but I would like to
use Vim to enter that string (because the string might be long and I want to
use Vim's editing capability while entering it).
Answer: You can call vim with a file path of your choice:
f... |
Finding ranges of specific character in a string
Question: I am working with python-3.x on windows 7. i have a string consists of
millions of characters. consider for example
ATCGNNNATCGATNNNNNATCGANTCG
I want to get the ranges which are N. in here [[4,7],[13,18],[23,24]]. I can
not just take posit... |
How to create a shortcut in startmenu using setuptools windows installer
Question: I want to create a start menu or Desktop shortcut for my Python windows
installer package. I am trying to follow
<https://docs.python.org/3.4/distutils/builtdist.html#the-postinstallation-
script>
Here is my script;
impor... |
why i failed to join two dataframes when using python pandas?
Question:
import pandas as pd
from pandas import DataFrame
l=[(1,10),(2,5), (3,7)]
l2=[(1,5), (2,6), (3,8)]
l3=[(2,3), (1,9), (3,9)]
d1=DataFrame(l)
d2=DataFrame(l2)
d3=DataFrame(l3)
j1=d1.join(d2, how='lef... |
Making requests @python
Question: I get many errors while trying to execute code:
import requests
#import bs4 --not sure if it's necessary
from bs4 import BeautifulSoup
core = 'http://wwww.lolnexus.com'
name = input('\nName: ')
region = input('\nRegion NA | EUW | EUNE | BR | TR | RU ... |
How to extract image geodata out of flickr xml image data with python?
Question: I'm researching the issue of electronic waste and I'm using this code in
flickrapi py module to get an xml data on Flickr images tagged with #e-waste.
import flickrapi
import xml
api_key='myAPI key'
api_secret ='... |
Python returns 5 digit timestamp, what is this?
Question: I'm a PHP programmer doing a bit of Python (3.4) just because it's way easier
to do it in Python. My script converts a .xlsx file, into many .csv files (one
.csv per sheet).
Here is the code:
wb = xlrd.open_workbook(filepath)
for i in ra... |
Placeholder to set different frequencies of sin wave output to each key press
Question: I want to use the placeholder %f to set different frequencies for my sin wave
sound output, for each key. However, I get the error message 'SyntaxError:
can't assign to literal'. I checked to see if my syntax was incorrect, though
I... |
Remove integer values from line in a file in python
Question: How to remove integer values in lines of a file in python? This is my present
output
നട തുറന്നപ്പോള് കൃഷ്ണന് പുഞ്ചിരിച്ചു കൊണ്ട് നില്ക്കുക ആയിരുന്നു 1.
എന്തോ പറയുന്ന പോലെ തോന്നി 2.
കള്ള കൃഷ്ണന് 3.
അവന് എന്നും ഇങ്ങനേ തന്നെ ആയിരു... |
Python: how to reload modules that have been imported with *
Question: I know that if I import a module by name `import(moduleName)`, then I can
reload it with `reload(moduleName)`
But, I am importing a bunch of modules with a Kleene star:
from proj import *
How can I reload them in this case?
A... |
python BeautifulSoup finding certain things in a table
Question: Folks, Ive managed to get beautifulsoup to scrape a page with the following
html = response.read()
soup = BeautifulSoup(html)
links = soup.findAll('a')
There are several occurrences of
<A href="javascript:Set_V... |
Pyinstaller fails with Python FBX
Question: I wrote a simple test script for Python FBX from Autodesk
(<http://www.autodesk.com/products/fbx/overview>). It reads an .FBX file and
prints out some information on the file's contents.
It works fine when running the .py but when using Pyinstaller to turn it into
an EXE, it... |
Using a COM dll in python?
Question: I need to use an COM dll (made in CSharp) in my python project. I tried to
follow this example [Using COM Objects in Scripting Languages -- Part 2
(Python)](http://www.codeproject.com/Articles/73880/Using-COM-Objects-in-
Scripting-Languages-Part-Py), but I dont have success.
**My p... |
Encoding in Python - non-English characters into a URL
Question: I’m trying bit for bit to write a geocoding script. There is a Danish
(official and free) web service, where I enter an address in the URL and get a
json file with all needed info.
I can’t find the right way to translate my Danish characters (æ,ø,å) when... |
Issue in return of Image variable from django view (numpy array) to template
Question: I am a newbie in python/django/web development.
I am facing an issue with returning my image from my `django view` to my
`django template`.
I have a dummy button on my HTML page which calls a function in my `views.py`.
This functio... |
Using Flask, how can I download a file from a user-given URL?
Question: I'm writing (what was supposed to be) a quick application on an OpenShift
server running a Python 3.3 cartridge with Flask. Here's what I want:
I need a Flask method for getting a file from a URL and saving that file to
disk.
edit: I should clari... |
Permutating lists too large for RAM in Python
Question: I have written a program to read a list of words from a text file (one word
per line) and combine them to produce every permutation of 3 words before
writing an output file of the permutations, again one per line.
import itertools
wordList ... |
How to get precipitation/rainfall through weather api?
Question: I tired [Open Weather Map](http://openweathermap.org/current) because the docs
say it has "rain", but when I call it it doesn't. So I tried [Python Weather
API](https://code.google.com/p/python-weather-api/wiki/Examples) but none of
those options from wea... |
Bottle Python Error 404: Not found: '/'
Question: I am very new to using bottle but whenever I try to run my programs I always
get the error Error 404: Not Found '/'. The app in my example is not fully
functional yet but it should at least display something on the screen. Even
with fully functional programs this happen... |
In Python, what's the best way to get an unknown int from a string?
Question: **SOLUTION:** Ok guys I ended up using the following. It involves regular
expressions. This is what I was trying to get at.
matches = re.findall(r'My favorite chili was number \d+"', line) # gets 1 match
if matches: # i... |
getting error in canny edge detection
Question: i am trying to write a code using opencv python that automatically get canny
threshold values instead of doing them manually every time.
img= cv2.imread('micro.png',0)
output = np.zeros(img.shape, img.dtype)
# Otsu's thresholding
ret2,highthresh... |
changing global variable with thread in Python
Question: I am trying to write a script updating a global variable every 10 seconds. For
simplicity let's just increment `q` once teach time
import time, threading
q = 0
def f(q):
# get asset position every 10 seconds:
q += 1
... |
pick a random line from a very big file, from command line
Question: Suppose you have a very big file, and it'd be to expensive to go through all
the lines, or to slow.
How would you pick a line at random (preferably from command line, or python)?
Answer: You can try this from the command line - not sure if totally ... |
Sphinx autodoc not importing anything?
Question: I'm trying to use `sphinx` (in conjunction with `autodoc` and `numpydoc`) to
document my module, but after the basic setup, running `make html` produces
just the basic html with nothing from the docstrings included. I'm running
Python 3.3, the outline of the project stru... |
column wise dictionary creation using python
Question: How to make a columnwise dictionary from csv using python?
name, lastname, hobby
jhon, g, fishing
mike, a, boxing
tom, v, sking
output should be :
name = {1 : 'jhon', 2:'mike', 3:'tom'}
lastname = {1 : 'g', 2:'a',... |
Can a dictionary be passed directly to instantiate another object in python
Question: I'm experimenting with parse.com as a db for my django app. I've installed
parse_rest.
I have a list of dictionaries, with each dictionary of the form:
all_practices = {'a':value1, 'b':value2 ...}
according to th... |
how to insert tabs instead of spaces when creating xml files in python
Question: I m using
[Creating a simple XML file using
python](http://stackoverflow.com/questions/3605680/creating-a-simple-xml-file-
using-python)
and
[inserting newlines in xml file generated via xml.etree.ElementTree in
python](http://stackover... |
Python OpenCV : Rubiks cube solver color extraction
Question: **Description:**
I am working on solving rubiks cube using Python & OpenCV. For this purpose I
am trying to extract all the colors of the cubies(individual cube pieces) and
then applying appropriate algorithm(which I've designed, no issues there).
**The pr... |
Import Excel to Matlab without numeric data appearing in scientific notation
Question: My question is hopefully a simple one for experienced Matlab users. How can I
import data in an Excel sheet to Matlab without Matlab automatically
converting the numeric data to scientific notation?
The data I'm working with are ID ... |
Fast selection of a Timestamp range in hierarchically indexed pandas data in Python
Question: Having a DataFrame with tz-aware DatetimeIndex the below is a fast way of
selecting multiple rows between two dates for left inclusive, right exclusive
intervals:
import pandas as pd
start_ts = pd.Timestamp(... |
decorator inside class not getting values
Question: I have a decorator that validates a json response that I obtain using
requests. I also wrapped some requests logic into a class which accepts a
schema that the decorator needs to validate. I tried to use the decorator on
the get function of the class but i get a type ... |
Python regular expression to extract optional number at the end of string
Question: I'm trying to write a Python regular expression that can parse strings of the
type `"<name>(<number>)"`, where `<number>` is optional.
For example, if I pass `'sclkout'`, then there is no number at the end, so it
should just match `'sc... |
Python add numbers in a list
Question: Anyone can help me with these? Basically I have list begin created as shown
below:
>>> item
[('apple', 7, 'population'), ('apple', 9, 'population'), ('apple', 3, 'disease'), ('orange', 6, 'population')]
I want to combine the result of the object only when ... |
Python - read 10min from log file
Question: I need some tool to read latest 10 minutes entry in my log file, and if some
words are logged then print some text.
log file:
23.07.2014 09:22:11 INFO Logging.LogEvent 0 Failed login [email protected]
23.07.2014 09:29:02 INFO Logging.LogEvent 0 log... |
How to overcome version incompatibility with Abaqus and Numpy (Python's library)?
Question: I want to run an external library of python called `NLopt` within Abaqus
through python. The issue is that the NLopt I found is compiled against the
latest release of Numpy, **i.e. 1.9** , whereas Abaqus 6.13-2 is compiled
again... |
Selecting Selected line in listbox python tkinter
Question: Hi i have a question to ask regarding Python Tkinter Listbox. when i select
the value, what must i add into my code so that the Listbox would return the
value? There is no need for multiple selection. Or, can i add in a button to
execute a command, while putti... |
passing functions as arguments in other functions python
Question: I have these functions, and I'm getting errors, with the do_twice functions,
but I'm having problems debugging it
#!/usr/bin/python
#functins exercise 3.4
def do_twice(f):
f()
f()
def do_four(f):
... |
Python to exe: py2exe issues with pkg_resources
Question: I've built an application in Python that I'd like to distribute to my
enterprise and installing Python on each machine is unfortunately not an
option. I'd like to convert the application to an .exe so that users can run
my application with shortcut on their desk... |
Is there a way to gray out (disable) a tkinter Frame?
Question: I want to create a GUI in tkinter with two Frames, and have the bottom Frame
grayed out until some event happens.
**Below is some example code:**
from tkinter import *
from tkinter import ttk
def enable():
frame2.state(... |
Removing \r\n from a Python list after importing with readlines
Question: I have saved a list of ticker symbols into a text file as follows:
MMM
ABT
ABBV
ANF
....
Then I use readlines to put the symbols into a Python list:
stocks = open(textfile).readlines()
How... |
TypeError: Can't convert 'int' object to str implicitly *Python*
Question: For an assignment i am trying to get the results of a form "age" and to add
one to that number using python. The form will have users enter their age and
result should be their age next year.
Here is what i have thus far:
import ... |
AIFF-C file cannot be read with aifc module in python
Question: I am trying to read a compressed .aiff file stored on my local directory. I
get this;
>>>import aifc
>>>s = aifc.open('/Users/machinename/Desktop/folder/AudioTrack.aiff','r')
Traceback (most recent call last):
File "<stdin>", l... |
python use each line in for pool probleme
Question: i'm programming a script that fetch the http response and searching for 200
responses i need to make url like this : <http://exemple.com/string+number>
like : <http://exemple.com/hello123> hello string is in sites.txt and some
other strings , and i want to check them ... |
Checking using language heuristics
Question: so I'm doing some coding with python 2.7 and would like to implement language
heuristics to check for certain related keywords within a text file. I'm aware
of many language heuristics dictionary are coded in java and therefore would
like to ask the expert opinion of the com... |
python script from youtube video doesn't work
Question: I am trying to learn python from this youtube video:
<https://www.youtube.com/watch?v=RrPZza_vZ3w>
In the video they have given the viewers a script to run:
">>> import urllib"
">>> u = urllib.urlopen('http://ctabustracker.com/bustime/map/... |
Sublime text3 and virtualenvs
Question: I'm totally new with sublime3, but i couldn't find anything helpful for my
problem...
I've differents virtualenvs (made with virtualenwrapper) and I'd like to be
able to specify which venv to use with each project
Since I'm using SublimeREPL plugin to have custom builds, how ca... |
igraph graph.data.frame silently converts factors to character vectors
Question: Today I learned that igraph silently loses factors on graph.data.frame, so
factors in the vertex data frame are converted to character vectors. Is there
a way to retain the factor type e.g. for `V(g)$factor_var` and `df <-
get.data.frame(g... |
Python RaspberryPi GPIO Event Detection in Tkinter Failing
Question: I'm having a strange problem detecting GPIO events on the Raspberry Pi using
Python with Tkinter.
Once the `startGameButton` is clicked, which calls the `start_game` function,
a GPIO event is added in the `try` block, and a while loop runs for 30
sec... |
print statement not appearing in terminal
Question: I'm starting to play with scikit-learn after enjoying my AI class last
semester. I have no prior experience with python (we used WEKA) so I set up
python3 with a virtual env that has all the packages. I've activated the
virtual env and try running the below code via `... |
python: encode a url with percentage signs?
Question: I am trying to convert the following url
http://www.website.com/search/si/1/doctors/Vancouver, BC
to
http://www.website.com/search/si/1/doctors/Vancouver%2C%20BC
I tried
urllib.quote('http://www.website.com/se... |
How would I handle the event of a thread finishing in python?
Question: Say I am parsing data from a few different exchanges, I want each extra to run
simultaneously so I start each one up in its own process, but inside each
process I want to add output string to a list then return that list to the
main and output it t... |
Python : How to get sum of all values until a specific key is reached in dictionary
Question: I am new to python and have a doubt regarding dictionary operations.
I am maintaining a dictionary as follows -
dict = {counter:distance}.
**For example -**
dict = {1:1, 2:10, 3:27, 4:10... |
How to generate RequestToken URL for Google API
Question: I'm writing Python 2.7 desktop application which needs to access Google
Spreadsheets using OAuth 2.0. I'va found a library for Google Spreadsheets for
python [here](https://github.com/burnash/gspread) which uses
[this](https://github.com/google/oauth2client) pyt... |
Why do I have to restart the tcp_server program once it receives the data?
Question: I'm using a simple tcp_server in python. Here is the code:-
import socket
TCP_IP = '127.0.0.1'
TCP_PORT = 5005
BUFFER_SIZE = 1024
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind... |
Unable to install carbon using pip?
Question: I am trying to install carbon on my local machine using pip However, seems
like it does not work not sure what is wrong ? Error log attached below ? Can
someone help ?
Link: <http://graphite.wikidot.com/downloads>
pip install carbon
Error:
... |
element typemap + stl_vector.i typemap + ??? --> wrapped function taking list of elems
Question: Let's say I have an arbitrary non-trivial type `A` that I can write typemaps
for. In particular, let's say that I know how to convert `std::strings` into
`A` and that I have typemaps from strings in the target language to `... |
How to count similar domains in emails and print every domain only once[python]?
Question: I have dataset of 10 hotmail emails, 4 gmails, 3 mail.com. I want to analyze
list of emails and print how many of each domain(hotmail,gmail etc) is there
and print out. But i do it in a very bruteforce way. I know python has eleg... |
Reading a sqlite3.Binary object with numpy.genfromtxt
Question: I have a text file that containes a large string that was originally a binary
blob in an SQL column. I would like to read the data using `numpy.genfromtxt`
and convert the text to a 1D numpy array and then to a binary blob to be
imported later into SQL usi... |
(Python) How to make python program take a random line from a .txt file?
Question: Hello i am new to python and i would like your help So i just start learning
and the first thing came on my mind is Why not edit a simlpe program ! Well i
want to take a line (a username) and put it in an existing code
Here a part of th... |
find and replace with multiple for loops in Python
Question: I want to update a text file so that all consecutive capital letters have a
space between them. My approach was to use two `for` loops while reading the
file line by line.
import sys, fileinput
ActiveFileR = open('text.txt', 'r')
A... |
An error when running an example
Question: I am trying to use the `numpy.fft.fft`.
When I run the example in the bottom of this page
([numpy.fft.fft](http://docs.scipy.org/doc/numpy/reference/generated/numpy.fft.fft.html#numpy.fft.fft)),
there is an error and the figure is weird.
How to make it right? I guess the err... |
Calling a Cython Function form C Windowsx64
Question: after a long search without any results, i need some help.
I'm trying to call a Cython function form C. I have the following Code:
**print.pyx**
cdef public int grail(int i, int a): # public function declaration
return (i+a)
**modul.c*... |
Python one-liner that answers: Do any of these inputs return True for this function?
Question: Goal: Is there a built-in Python function (or one-liner) which will submit
arguments to a function, but only until the function returns `True` for the
first time? I would like to be able to answer the question
> "Do _any_ of... |
cats() got an unexpected keyword argument 'pk'
Question: I'm a amature django web developer. I have a problam with Django. this error
is "cats() got an unexpected keyword argument 'pk'". please see my codes and
help me.
Request Method: GET
Request URL: http://127.0.0.1:8000/1
Django Version: 1... |
Python Thread class variable is blank
Question: I've been trying to fix this issue for the past few hours, and i just can't
figure out what i'm doing wrong!
I have a single python file:
REFRESH_RATE=10.0
MAX_SECONDS=30
class user_manager:
users={}
def __init__(self,queue,sign_pr... |
psycopg2 across python files
Question: I am writing a Python application (console based) that makes use of a
PostgreSQL database (via psycopg2) and R (via rpy). It is a large procedure-
based application and involves several steps and sometimes repeating of steps
and do not always involve all steps.
I have is the foll... |
In python's Bokeh, how can I remove text above the plot?
Question: With the following code:
import bokeh.plotting as bplt
bplt.output_file('output.html', mode="cdn")
I get an html file with my graph(s); but it has the text:
You have 1 plots
Close All Plots
Above the gra... |
ImportError: cannot import name choice when importing sklearn.mixture
Question: I am using scikit learn 0.15.0. When I try to import sklearn.mixture I get
ImportError: cannot import name choice
Any ideas?
===================================================================
In [1]: **from sklearn import ... |
Sparse matrix multiplication when results' sparsity is known (in python|scipy|cython)
Question: Suppose we want to compute C=A*B for given sparse matrices A,B but are
interested in a very small subset of entries of C, represented by a list of
index pairs:
rows=[i1, i2, i3 ... ]
cols=[j1, j2, j3 ... ]
Both A and B... |
Python file wrapper, best design?
Question: I need to parse a domain specific configuration file, but before I begin
pulling the gold out of it, I want to remove the comments.
Once comments are removed, I still want to be able to use things like
`getline()`, `seek()` and `tell()`
(the offsets in seeking due to large ... |
How to run an infinite loop in background and stop it?
Question: Here is my problem: Using Tkinter, I want to click a button and launch a
python script. This python script is now a module (I don't know if it s the
best way to do it) imported to my main script. This script should be running
in background. There is a met... |
Easy way to send a message to an XMPP/Jabber conference room? (Shell or Python, Debian wheezy)
Question: What is an easy way to send a message to a XMPP/Jabber conference room? Either
at the command line (Shell), or by using Python? Ideally, all commands and/or
libraries should be available in Debian wheezy (or jessie)... |
How can a file (say image) be stored inside a MongoDB collection, using command line?
Question: There is option of GridFS but that requires a driver(some language). Can't we
insert a file in a table and display as a field(may b the path of file)? I
tried one approach using Gridfs in python.
from pymongo import MongoCl... |
Python: comparing two sets and writing results to a third set
Question: So this is what I have, I think what I'm looking for is pretty straight-
forward. I want to be able to take the items in set c2 that are not in c1 and
add those to c3. Sets c1 and c2 populate correctly. Any help is appreciated.
Thanks.
... |
SUDS Exception Imported Schema Failed
Question: I'm getting the error:
> Exception: imported schema (<http://www.w3.org/2001/XMLSchema>) at
> (<http://www.w3.org/2001/XMLSchema.x> sd), failed
when passing a Doctor (constructed with _ImportDoctor_) to the **suds**
_Client_ constructor.
I'm working on two _Windows_ ma... |
Python csv.DictReader - how to reverse output?
Question: I'm trying to reverse the way a file is read. I am using DictReader because I
want the contents in a Dictionary. I'd like to read the first line in the file
and use that for the Keys, then parse the file in reverse (bottom to top) kind
of like the linux "tac" com... |
Python: Memory-Efficiency of Assigning Variables and Calling Methods
Question: This has been bugging me for a while. I'm wondering about the comparative
memory-efficiency of assigning variables and calling methods. Consider, for
example:
> s = "foo"
> x = s.lower()
Versus
> x = "foo".lower()
Which one of these i... |
how to prevent failure of subprocess stopping the main process in python
Question: I wrote a python script to run a command called "gtdownload" on a bunch of
files with multiprocessing. The function "download" is where I am having
trouble with.
#/usr/bin/env python
import os, sys, subprocess
... |
Python re regex matching issue
Question: Ok please be gentle - this is my first stackoverflow question and I've
struggled with this for a few hours. I'm sure the answer is something obvious,
staring me in the face but I give up.
I'm trying to grab an element from a webpage (ie determine gender of a name)
from a name w... |
How to print é as '%C3%A9' in Python 2.7
Question: I want to convert '**é** ' to **%C3%A9** for URI request.
My code is like this:
import urllib
actor = "Bonnie Erbé"
I know that I can manually covert it by
print urllib.quote(u"Bonnie Erbé".encode("utf-8")).
However, I wa... |
How to use Python to extract data from the Met Office JSON download
Question: I am using Python 3.4.
I have started a project to download the UK Met Office Forecast data (in JSON
format) and use the information as a weather compensator for my home heating
system. I have succeeded in downloading the JSON datafile from ... |
External Module causes os.path.isfile to return incorrect answer
Question: I am running Python 2.7 under Windows7 on an iMAC (using BOOTCAMP) and have
encountered a strange problem or bug. Here is my problem script boiled down to
essentials:
import arcpy
import arcpy.mapping as mapping
import os
... |
Ports with python sockets, are they random?
Question: I am trying to learn python sockets, but am becoming very confused by the
results of the example code from the website ([found
here](http://www.tutorialspoint.com/python/python_networking.htm)).
The only modification I have made is replacing `socket.gethostname()` ... |
Implementing a "screen" command for windows machine using python
Question: So I am trying to do following:
1. I have _Cygwin_ enabled with _screen_ and _ssh daemon_ in _Windows 7_.
2. I create a new screen using the command `screen -dmS "my_screen"` on my _Windows_ machine.
3. I _ssh_ to the _Windows_ machine fr... |
Python: convert JSON to XML
Question: Are you aware of any good Python `JSON <-> XML` parser that could do the
following:
Use the following JSON:
var json = {
"root_element_name" : {
"attr1" : "value",
"attr2" : "value",
"elements": {
"element_... |
Recursion depth exceeded
Question: I have a problem with my ship generation in the Battleship game! Sometimes
when I run the code I get the error:
RuntimeError: maximum recursion depth exceeded while calling a Python object
Here is the code, I give you all if it can help. The problem is in the "pic... |
rounding up time in python error
Question: I get the following error when trying to round up time,
AttributeError: type object 'datetime.datetime' has no attribute 'timedelta'
fajr_jamaat1 printout is 1900-01-01 04:25:00 Please help?
from datetime import datetime, timedelta
... |
Django + wsgi = Forbidden 403
Question: So 403 error is here. My 000-default.conf from /etc/apache2/sites-available/:
<VirtualHost talkrecorder.ru:80>
ServerName talkrecorder.ru
ServerAlias www.talkrecorder.ru
ServerAdmin [email protected]
DocumentRoot /srv/www/sampleapp/
WSGIScrip... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.