text stringlengths 226 34.5k |
|---|
How to handle exeption in threading with queue in python?
Question: This is never print: "Exeption in threadfuncqueue handled by threadfuncqueue",
"Exeption in threadfuncqueue handled by main thread" and "thread test with
queue passed". Never quitting!
from threading import Thread
from Queue import Q... |
fileinput, inplace filtering, encoding
Question: I am attempting to use the `fileinput` module's [inplace filtering
feature](https://docs.python.org/dev/library/fileinput.html#fileinput.FileInput)
to rewrite an input file in place.
Needed to set encoding (both for read and write) to `latin-1` and attempted to
pass `op... |
Can't call static method inside class
Question: This is what i am trying to do call a static method inside a class to populate
the class variable.
import sys
import os
from HelpingData import *
class Inventory(object):
shipping_cost = 400.0
total_stock = calculate_tota... |
Returning Cython array
Question: How does one properly initialize and return a Cython array? For instance:
cdef public double* cyTest(double[] input):
cdef double output[3]
for i in xrange(3):
output[i] = input[i]**2
print 'loop: ' + str(output[i])
return output
... |
edit a file line by line interactively from user input in python
Question: I want to know how to edit a file on the fly row by row in python.
For example I have a text file where I usually have:
key value
key value
key value
key value
key value
...
they are not necessarily the ... |
How to pass non-hard-coded parameter to Python decorator?
Question: My goal is to create a trivial unit test decorator, which executes a function
and, if it succeeds, do nothing, if it doesn't, print "FAILURE" and all its
parameters. I do know about the builtin `unittest` package. I'm doing this to
learn decorators. I'... |
fix error: jit decorator takes exactly one argument, 4 given
Question: I have the following class definition:
class GentleBoostC(object):
def __init__(self):
# do init stuff
# add jit in order to speed up the code
@jit
@void (float_[:,:],int_[:],int_)
... |
python: converting datetime format
Question: I have the following format:
`"Wed Jun 25 15:38:29 PDT 2014"` and I would like to convert it to
`"2014-06-25 15:38:29"`, i.e. `"%Y-%m-%d %H:%M:%S"`
Code:
import time
import datetime
rawtime = "Wed Jun 25 15:38:29 PDT 2014"
dt ... |
Python equivalent of R's head and tail function
Question: I want to preview a Pandas dataframe. I would use head(mymatrix) in R, but I
do not know how to do this in Pandas Python.
When I type
df.head(10) I get...
<class 'pandas.core.frame.DataFrame'>
Int64Index: 10 entries, 0 to 9
Data columns ... |
How to create a python decorator programatically
Question: I am writing an app that creates/provides various Python decorators. I'd like
this app to be localized, including the names of the decorators. The
decorators would ultimately be used by other developers who are using my app
as a framework (think of my app as a ... |
Django tutorial: unexpected indent error
Question: Here is my model.py code :
from django.db import models
# Create your models here.
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __str_... |
Postgres: Is there a way of executing code following a INSERT statement?
Question: This may seem strange, but I was curious to know if it was possible for a code
block to be executed following an INSERT statement in a postgres database?
Specifically, I'm interested in executing Python code after an INSERT
statement ha... |
python multiprocessing example itertools multple lists
Question: I have a very simple application with a nested for-loop and it can take
minutes to hours to run depending on the amount of data.
I got started with the multiprocessing lib in python. I tried implementing it
in is most basic form, and even though my code ... |
make_server() check if bind to port succeeded
Question: _In Python 2 and 3k_ , using `wsgi.simple_server.make_server(host, port, app)`
does not raise an exception when the port is already in used. Instead, a call
to `.server_forever()` or `.handle_request()` simply blocks until the other
port closes and the next connec... |
Alternatives to using functools.partial with string methods
Question: A profiling of my code shows that methods `split` and `strip` of `str` objects
are amongst the the most called functions.
It happens that I use constructs such as:
with open(filename, "r") as my_file:
for line in my_file:
... |
Waiting for a table to load completely using selenium with python
Question: I want to scrape some data from a page which is in a table. So I am only
bothered about the data in the table. Earlier I was using Mechanize, but I
found sometimes some of the data are missing, especially in the bottom of the
table. Googling, I... |
PyPDF2 won't import
Question: Hi I'm just getting started with python and trying to get some requisite
libraries installed. Using Python 3.4.1 on OS X. I have installed PyPDF2 (with
supposed success), yet I cannot seem to use the tools:
sh-3.2# port select --list python
Available versions for... |
IntelliJ IDEA - how to map remote PYTHONPATH to local environment?
Question: I'm using python remote interpreter in IntelliJ(13.1), and using "composes"
modules which are installed on server.
By importing the module like follwing, I can use the module without any
problem, but I get warn "No module named composes".
... |
Merge multiple csv file based on a template header in python
Question: I have multiple csv files that all have more or less the same headers. some
might have all the headers some might not have them all. I want to use a
common csv file that will have only the headers and merge them all.
sample header:
a... |
Can't log in to website with Python requests session module
Question: I am just starting out with web scraping. For my first project, I'm trying to
log into artofproblemsolving.com using requests.Session() and access another
user's account. Here is my code:
import requests
LOGIN_URL = 'https://w... |
python multiprocessor how to stop all threads when on one of them find the result?
Question: I am trying to run my code in parallel using the python "from multiprocessing
import Process, Value" model.However, I am creating a shared variable and
using it as flag, so if one process find the result it will set the flag va... |
Curses using changing data
Question: I have the following code. The number range increments by 1 each time. i.e 1-9
then 2-10 etc. I want to display this within a shell window using python via
curses.
The goal is to have a list of text that is constantly changing.
from itertools import cycle
import ... |
sending and recieving through serial
Question: I have got a simple program running in the uno that measures the distance
using ping sensor and now i am trying to control some servos based on the
distance in python but the conditional thingy is not working even in a simple
code like this
import serial
... |
Python findall, regex
Question: I have this text:
u'times_viewed': 12268,
u'url': u'/photo/79169307/30-seconds-light',
u'user': {u'affection': 63962,
How can I just get out this string: `"/photo/79169307/30-seconds-light"`?
I am trying with regex and `findall`:
list = ... |
Tuple for multiprocessing.Array in python
Question: I'm struggling with multiprocessing in python. I want to put list of tuple in
multiprocessing.Array, but I can't find the typecode for tuple.
This is the code, and I want to know how to write "type_of_tuple" for arr in
main function.
from multiprocessi... |
Google Maps with Python 3.4.1
Question: I am trying to write a script to assign the Latitude and Longitude of a
location based on the address similar to what is fantastically explained here:
<http://py-googlemaps.sourceforge.net> The only problem is that, that code is
written for Python 2.3-2.6. Does anyone know how I ... |
python get html page after login
Question: I want to login to famjia.com and i try all the methods, none of them works
for me. I tried using requests and urllib but they don't work. Help? These is
my code. Thanks in advance. import requests
URL = 'http://www.famjia.com/portal/intranet/famjiaPaper/'
... |
Single process code performs faster than Multiprocessing - MCVE
Question: My attempt to speed up one of my applications using Multiprocessing resulted
in lower performance. I am sure it is a design flaw, but that is the point of
discussion- How to better approach this problem in order to take advantage of
multiprocessi... |
How to get the body text of email with imaplib?
Question: I am in python3.4 .
import imaplib
import email
user="XXXX"
password="YYYY"
con=imaplib.IMAP4_SSL('imap.gmail.com')
con.login(user,password)
con.list()
con.select("INBOX")
result,data=con.fetch(b'1', '(RFC822)'... |
Does Behave (BDD) work with Python 3.4?
Question: I am using [Behave](http://pythonhosted.org/behave/install.html) (BDD for
Python) and have been trying to enable JUnit output without success. After
troubleshooting, I realized that I am getting the following error message
**only** when using **Python 3.4** :
... |
Difference between / in C++ and Python
Question: **Using Python 2.7**
I was trying to solve the Reverse Polish Notation problem on LeetCodeOJ.
[RPN on LeetCodeOJ](https://oj.leetcode.com/problems/evaluate-reverse-polish-
notation/)
I wrote my straightforward solution in Python as follows:
class Soluti... |
Python requests speed up using keep-alive
Question: In the HTTP protocol you can send many requests in one socket using keep-alive
and then receive the response from server at once, so that will significantly
speed up whole process. Is there any way to do this in python requests lib? Or
are there any other ways to spee... |
ImportError: No module named libxml2
Question: I am using Ubuntu 12.04.2 LTS. I have used libxml2 in my python script and
when I try to run it, gives error
Traceback (most recent call last):
File "deploy.py", line 3, in <module>
import libxml2
ImportError: No module named libxml2
I trie... |
How can I read the accelerometer in my windows tablet with python?
Question: I have an accelerometer in my tablet, that I can read from within javascript.
How can I access this data in python? Is there some ctypes trickery I can use
to call a windows 8 Sensor API function?
Answer: Horrible hack - start up a webserve... |
multiprocessing do not work
Question: I am working on Ubuntu 12 with 8 CPU3 as reported by the System monitor.
the testing code is
import multiprocessing as mp
def square(x):
return x**2
if __name__ == '__main__':
pool=mp.Pool(processes=4)
... |
cxfreeze command not found in windows
Question: I installed [cx_Freeze](http://cx-freeze.sourceforge.net/) via the _msi
installer_ on my Windows 7 pc. It told me the installation was successful and
running `pip install cx_Freeze` doesn't cause anything.
Anyway when I try to run the command `cxfreeze --version` in the ... |
How to see a Google+ user's circles with google-api-python-client
Question: I'm trying to access a user's circles in this way:
from apiclient.discovery import build
service = build('plus','v1',developerKey=my_developer_key) # <-- NOT the user's token
people_request = service.people().list(userId=... |
swig: extending a class template to provide __str__
Question: Say you have a template class `Foo`, and you want to wrap it with Swig
transparently so that you can print the class:
>>> from example import *
>>> f = Foo2()
>>> print(f)
In Foo class!
I have followed [this post](http://stac... |
python search in a string with find
Question: i'm trying to find a string in the headers of response after login in
wordpress script , so i tried with this find method :
import urllib, urllib2, os, sys, requests , re
....
....
req = urllib2.Request(url, urllib.urlencode(dict(data)), dict(head... |
Python string to date, date to string
Question: I have a list of blog posts with two columns. The date they were created and
the unique ID of the person creating them.
I want to return the date of the most recent blog post for each unique ID.
Simple, but all of the date values are stored in strings. And all of the
str... |
Django aggregate Count only True values
Question: I'm using aggregate to get the count of a column of booleans. I want the
number of True values.
DJANGO CODE:
count = Model.objects.filter(id=pk).aggregate(bool_col=Count('my_bool_col')
This returns the count of all rows.
SQL QUERY SHOULD BE:
... |
Python 3 basic auth with pinnaclesports API
Question: i am trying to grab betting lines with python from pinnaclesports using their
API <http://www.pinnaclesports.com/api-xml/manual>
which requires basic authentication (<http://www.pinnaclesports.com/api-
xml/manual#authentication>):
> Authentication
>
> API use HTTP... |
Openshift doesn't perform syncdb on push
Question: I have the following error when performing my pushes and app-restart:
remote: Executing 'python /var/lib/openshift/6783687678687678/app-root/runtime/repo//wsgi/openshift/manage.py syncdb --noinput'
remote: python: can't open file '/var/lib/open... |
Python: Must non-built-in exceptions be imported in order to catch them?
Question: I'm trying to catch some exceptions thrown by the `requests` library, with the
following try-except block:
try:
get = requests.get((requester.batchesUrl)+str(id)+'/', auth=requester.auth)
except (Connecti... |
python requests session failed to read the response after reading a big (more than 50mb) response content
Question: When using python requests to access some rest api, I am using request's
session object. I faced a issue, when the first request is reading large
content (more than 50mb) then the subsequent http request ... |
Getting TemplateDoesNoteExsist Error in Django
Question:
TemplateDoesNotExist at /
index.html
Request Method: GET
Request URL:
Django Version: 1.6.5
Exception Type: TemplateDoesNotExist
Exception Value:
index.html
Exception Location: C:\Python27\lib\site-packages\django\temp... |
scikit-learn's GridSearchCV stops working when n_jobs>1
Question: I have previously asked
[here](http://stackoverflow.com/questions/25249212/scikit-grid-search-for-knn-
regression-valueerror-array-contains-nan-or-infinity) come up with following
lines of code:
parameters = [{'weights': ['uniform'], 'n_ne... |
Django Tastypie prepend_urls error
Question: Django-tastypie error. I am trying to prepend_urls so that I can list friends
for a user but I get an error **" NameError at /api/v1/friends/user/1/ global
name 'url' is not defined"**. Here is the code for the Friends Resource.
class FriendsResource(ModelReso... |
directory structure for a project that mixes C++ and Python
Question: Say you want want to create a programming project that mixes _C++_ and
_Python_. The **Foo** _C++_ project structure uses _CMake_ , and a _Python_
module is created by using _Swig_. The tree structure would look something
like this:
├─... |
GeekTool only iterates through my python loop once
Question: I built a very simple script with PRAW that prints the top 10 link titles on
reddit.com/r/worldnews. I want this to work with GeekTool, but only the
following shows up:
"TOP 10 NEWS ON REDDIT
1 NEWS TITLE
2 "
I don't know why that happens since when runni... |
Python script don't receive exit signal sent by supervisor
Question: I'm running a python script that creates a Tornado server, the server is run
by supervisor. I want to gracefully terminate all WebSocket client connections
when a **supervisorctl reload** is issued (normally after a deploy).
My problem is that I'm no... |
Logical url patterns - django | python
Question: I'm building a social network and I want to show special content when a user
is logged in and he accesses to his public profile url (so i'll show
customization tools). I've written code to return the user name and match it
with the regex, but I don't know how to only hav... |
How to parse XML with xml.sax and why it's not working
Question: I have a piece of code whitch in my opinion should work:
#!/usr/bin/env python3
import xml.sax
import xml.sax.handler
class MyClass:
def load_from_file(self, filename):
class MyXmlHandler(xml.sax.ha... |
Urllib2 Error in pip under Windows
Question: I have some trouble running pip form ActiveState Python 2.7.2 under Windows.
We use a proxy, which might be part of the issue. The proxy is a non-
authenticating proxy. The proxy settings from the system, manually in e.g.
Firefox or with some simple Python code work fine:
T... |
Seaborn FactorPlot throws TypeError
Question: sns.FactorPlot is throwing me a TypeError when it tries to set_title. This
happens on an example dataframe, but more worryingly, also happens on the
example from the documentation.
So
import seaborn as sns
exercise = sns.load_dataset('exercise')
sns.... |
conditional breakpoint using pdb
Question: Sounds like I'm missing something extremely simple, I'm trying to set a
breakpoint in my python code using:
if(some condition):
pdb.set_trace()
My error in the code comes after a large number of iterations..difficult to
debug using print etc. I... |
Creating multiple *.cfg files Python
Question: I'm working with *.cfg files. The file can be read in a text editor like gedit
and has this format:
% some comments
VAR_1= 1
%
% More comments
ANOTHER_VAR= -8
%
% comments again
VAR_THE_COMEBACK= 10
I want to create multiple... |
Python live dependency installation via pip (PyPI)
Question: I want to pull the live version of a package as a dependency of another
package I install with pip.
Now, I have already found out [how to install a live version of a package via
pip](http://stackoverflow.com/questions/23185238/easy-install-live-python-
libra... |
How do imports work in IPython
Question: I'm a little bewildered by exactly how import statements work in IPython. I've
turned up nothing through web searches.
Implicit relative imports work with Python 2, but I don't know if that's still
the case with IPython for Python 3.
Relative imports using the dot syntax dont ... |
List in a Loop and Subprocesses, Standard Output
Question: I want to call a subprocess in a for loop and put the vertical lines
horizontally in a list for printing them by separating by comma. My code is
like this ;
import serial
import time
import subprocess ... |
How to make QTreeWidget dragging semi-transparent and keep itemWidgets
Question: i have a treeWidget with itemWidget set on columns, but after dragging the
widgets are gone, and the dropping indicator is opaque
1. How can i make the widget persist after dropping
2. How to make dropping indicator transparent ? ( i'... |
Getting Broken Pipe failure when sending Multipart/form-data
Question: I am trying to setup a server for handling multi-part form data in python. I
am trying to hit my python server with curl command.
I getting Broken Pip Failure error.
Can someone please help ?
PYTHON SERVER CODE :
from BaseHTTPServe... |
Importing module implicitly
Question: In a directory, I have two files: `A.py`, and `B.py`. Here is their content:
# A.py
import numpy
x = numpy.array([1, 2, 3])
print x
# B.py
import A
y = numpy.array([4, 5, 6])
print y
From Command Prompt (Windows 8), I ... |
python No plot or NameError UPDATE plot is visible but not as it should be
Question: I am attempting to create a "rolling spline" using polynomials via polyfit and
polyval.
However I either get an error that "offset" is not defined... or, the spline
doesn't plot.
My code is below, please offer suggestions or insights... |
Matplotlib doesn't show proper font on ubuntu 14.04
Question: I installed matplotlib with all dependencies on ubuntu 14.04 from source
Processing dependencies for matplotlib==1.3.1
Searching for nose==1.3.3
Best match: nose 1.3.3
Processing nose-1.3.3-py2.7.egg
Removing nose 1.3.1 from ea... |
igraph's Gomory–Hu tree not working?
Question: When I try the following with `python-igraph`:
from igraph import *
g= Graph()
g.add_vertices(3)
g.vs["name"] = ["0", "1", "3"]
g.add_edge("0", "1", weight=0.0)
g.add_edge("1", "3", weight=10.0)
g.add_edge("0", "3"... |
Using If statements in Python: If datetime.day == WEDNESDAY then call wed_module()
Question: Okay I want to call a different module for each day of the week in Python. My
code right now looks like this:
def today_Shift():
import time
import datetime
import calendar
print "... |
DLL load failed: %1 is not a valid Win32 application for NumPy
Question: I downloaded NumPy through Anaconda and copied and pasted the NumPy file from
there to the site-package file in the Python 27 folder.
I was trying to import NumPy from a 2.7.5 shell, and it gave me an error:
> DLL load failed: %1 is not a valid ... |
How can Flask/Python import config file that is one level up higher
Question: I'm writing a Flask web app and I ran into a small problem that really bothers
me. This is my microblog.py file:
from flask import Flask
from flask import render_template, flash, redirect
from forms import LoginForm
... |
Does igraph's gomory_hu_tree calculate the minimum cut tree?
Question: I'm trying to implement [this graph clustering algorithm (sec.
3.2)](http://projecteuclid.org/euclid.im/1109191029) with python-igraph. As I
do not want to calculate the minimum cut tree myself, I'm trying to use the
`gomory_hu_tree()` method. To pl... |
Log in with Python and Requests
Question: I've been trying to access a website with no API. I want to retreive my
current "queue" from the website. But it won't let me access this part of the
website if i'm not logged in. Here is my code :
login_data = {
'action': 'https://www.crunchyroll.com/?a... |
python regex, optionally match a word
Question: I have the following regex:
PackageQuantity:\b|Servings?PerContainer:\b|Servings?PerPackage:\b(\d+)
that supposed to match the following text:
ServingsPerContainer:about11
Blank white spaces are escaped for comfortability
the ide... |
when executing f2py fib1.f -m fib2 -h fib1.pyf I get the following error File " ^ SyntaxError: invalid syntax
Question: I am using `Mac 10.9` and running `Python 2.7.8`. Currently I am trying to use
`f2py`. I follow the example in the guide and typed
$ f2py -c fib1.f -m fib1
and I receive the follo... |
Python3-ldap KeyError: 'attributes'
Question: Using Python3.4 with the `python3-ldap` module loaded. Using the code:
from ldap3 import Server, Connection, SEARCH_SCOPE_WHOLE_SUBTREE, AUTO_BIND_NO_TLS #For title queires into LDAP
def GetTitle(u):
print(u)
t=[]
server ... |
Python round with `n // 1`
Question: I was wondering if there is any reason not to use the `//` operator to round a
number to an integer. I didn't see much on this topic or really know what to
look for to find out more.
>>> from random import random
>>> random() * 20 // 1
1.0
>>> random() * 2... |
How to create new console sessions in Python and work with them
Question: I'm trying to figure out how to work with consoles in Python. Let's say, I
have a Python2 script. And this script should create 3 consoles (bash or any
other) and provide different commands to them.
Example:
* Console #1 will be responsible f... |
Serial data over UDP Sockets in Python
Question: I may be going about this the wrong way but that's why I'm asking the
question.
I have a source of serial data that is connected to a SOC then streams the
serial data up to a socket on my server over UDP. The baud rate of the raw
data is 57600, I'm trying to use Python ... |
Cleanest data structure to use when interpreting data from neatly-structured user commands (in C++)
Question: I would like to write a simple in-house program that parses user commands
written in a language of our team's own invention (but based closely on
another program we are already familiar with). The command parse... |
Sentry logging in Django/Celery stopped working
Question: I have no idea whats wrong. So far logging worked fine (and I was relying on
that) but it seems to have stopped. I wrote a little test function (which does
not work either):
**core.tasks.py**
import logging
from celery.utils.log import get_ta... |
Strange Queue.PriorityQueue behaviour with multiprocessing in Python 2.7.6
Question: As you know from the title, I'm trying to use PriorityQueue with
multiprocessing. More precisely, I wanted to make shared PriorityQueue, wrote
some code and it doesn't run as I expected.
Look at the code:
import time
... |
How to use ipython without installing in every virtualenv?
Question: **Background**
I use Anaconda's IPython on my mac and it's a great tool for data exploration
and debugging. However, when I wish to use IPython for my programs that
require virtualenv (e.g. a Django web app), I don't want to have to reinstall
IPython... |
Some issues with Python regex findall
Question: Got string source :
string ="""
html,,
head,, profile http://gmpg.org/xfn/11 ,,
lang en-US ,,
title,, Some markright page.
,,title
,,head
"""
...which have to parse a... |
Python error: unsupported operand type(s) for -: 'float' and 'NoneType'
Question: My code is supposed to read and subtract two data lists from each other. Why
am I receiving this error, and how can I resolve it?
Here is the full error:
Traceback (most recent call last):
File "<stdin>", line 1, in ... |
Emulating a cURL command with Python
Question: I've got a cURL command that does what I need, and I'm trying to translate it
into python. Here's the cURL:
curl http://example.com:1234/faye -d 'message={"channel":"/test","data":"hello world"}'
This talks to a Faye server and publishes a message to t... |
Extract data from multi array from json
Question: I am new to python.I need to extract data from json file.
import urllib
import re
import json
text = urllib.urlopen("http://www.acer.com/wjws/ws/gdp/files/en/IN/-/latest/driver/63/-").read()
result = json.loads(text) # result is now a dic... |
How do I manipulate datetime (tick labels and limits) on a plot axis in Python?
Question: I have a plot created within a for loop with a list of datetimes as the x
values. The x ticks are labeled as dates, but I would like to display the hour
(i.e. 6, 12, 18, 24 repeating). I would also like to set xlim to wider than
t... |
Atom.core not found when in virtualenv
Question: I'm trying to use the google for content api for shopping via the gdata client
library and the atom library seems to be giving me an error.
This only happens when I try to run my code in a virtualenv.
Traceback (most recent call last):
File "/home/t... |
python: making array index generation more efficient/elegant
Question: I am trying to get some array indices with python. At the moment, the code
looks very cumbersome and I was wondering if I am doing it inefficiently or in
unpythonic style. So, I have an n-dimensional array and I am trying to
generate some indexes as... |
Speeding up video to image conversion
Question: I use
call(['avconv', '-i', 'video.mp4', '-vsync', '1','-r', '1','-an','-y','%5d.jpg'])
in Python. It works, but it goes through the videofile in realtime. How to
speed this up, so getting 60 pictures all in all, each second of the video
file does not... |
What are the file places after you package a python program?
Question: I am wanting to package my program that uses over files to store user data
locally, but I don't know what directory I should put in all the `json.load`
and `json.dump`. So right now, I have the directory equal to
`json.dump(somelist,open('/home/user... |
Python - Convert X, Y Rotation coordinates from Radians to Degrees
Question: I have been stuck working on this for hours and I'm not very good with this
kind of math so please bare with me.
I have 2 values that are in radians, `c[1]` and `c[3]`. I need to turn the
radians into degrees and I haven't the faintest idea w... |
Is there an usage `_tuple` in python?
Question: I read the official documentation for `collections.namedtuple` today and found
`_tuple` mentioned in the `__new__` method. I did not find where the `_tuple`
defined.
Here is the code, you can try it in Python - it does not raise any error.
>>> Point = name... |
AttributeError: 'str' object has no attribute 'tostring'
Question: Trying to convert image to string....
import requests
image = requests.get(image_url).content
image.tostring()
I get the error:
> AttributeError: 'str' object has no attribute 'tostring'
How do I turn this into something t... |
Keep console input line below output
Question: [EDIT:] I'm currently trying to make a small tcp chat application. Sending and
receiving messages already works fine... But the problem is:
When i start typing a message while i receive one... it appears after the text
I'm writing
Screenshot: <http://s7.directupload.net/... |
HTML button on client to run python script on server then send results to webpage on client
Question: I have seen some previous questions, that were similar but I couldn't find
anything like this. I have a webpage (on a server) and I would like the user
to click a button which will execute a python script. I want this ... |
flask sub function not yielding results
Question: I have a bunch of code (1300 lines) that is working correctly and I am trying
to incorporate flask into the picture. In order to do this, I an trying to use
flask.Response to call a function within my method, that calls another method
in my class.
Here is test code tha... |
Finding cosine similarity between 2 numbered datasets using Python
Question: I have numbered datasets of length 22 where each number can lie between 0 to 1
where it represents the percentage of that attribute.
[0.03, 0.15, 0.58, 0.1, 0, 0, 0.05, 0, 0, 0.07, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.01, 0]
... |
add items to a dictionary and save it to a txt file
Question: a few weeks ago i have started learning python.
Now i have started to create a program to create a dictionary, add an item1 as
a string, add an item2 wich consists of numbers and save it after that. But it
is not working the way i want it to. It seems like ... |
Google app engine, cloud sql, and django: no rdbms backend module
Question: I've been following a number of tutorials on setting up _google app engine_
(GAE) with their cloud SQL and django. The conclusion I've reached is most of
them get you to install a local copy of python and all the libs. Some even
fail to mention... |
LFU cache implementation in python
Question: I have implemented LFU cache in python with the help of Priority Queue
Implementation given at
<https://docs.python.org/2/library/heapq.html#priority-queue-implementation-
notes>
I have given code in the end of the post.
But I feel that code has some serious problems:
1\... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.