text stringlengths 226 34.5k |
|---|
Python UDP Network not receiving data
Question: **Computer A "sender":**
import socket
UDP_IP = "computer b ip address"
UDP_PORT 5005
MESSAGE = "HELLO!"
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
while True:
sock.sendto((bytes(MESSAGE, 'UTF-8')), (UDP_IP... |
Random String generator python
Question: I made a simple program in Python to generate a random string with 5 numbers
in it:
import random
numcount = 5
fstring = ""
for num in range(19): #strings are 19 characters long
if random.randint(0, 1) == 1:
x = random.ran... |
checking whether variable is dictionary in python - use 'is' or ==
Question: Summary: I have a variable called `'parent'` that is a dictionary in python. I
want to check if it is a `dict` object. However, using `"type(parent) is
dict"` gives me `'False'`.
NOTE: I have the following library loaded in my python script:
... |
global name 'sqrt' not defined
Question: I've created a function, `potential(x,K,B,N)`, where `x`,`K`,`B` are `numpy`
arrays and `N` is an integer. I'm trying to test the function in `iPython` but
I keep getting the error `"global name 'sqrt' not defined"`.
Here's a look at my code:
def potential(x,K,B,... |
how to pass command line string arguments and compare them python
Question: i want to comapre two strings by passing one string from command prompt, this
is sample code, when I pass `c://python sample.py x`, it is storing x1 as
x1=[' x '] now if I compare `sys.argv[1:]` with string 'x' its false, may be
its comparing `... |
Use git hooks to create an archive of files
Question: I want to create a zip file containing some of the files in the repo, and then
add and commit that as well as the files already in the repo.
I've changed `precommit` to this:
#!C:/Python34/python.exe
import tarfile, os
os.chdir("C:\proje... |
python-how to crawl past __VIEWSTATE
Question: im implementing a simple python crawler. i tested on .aspx site and realised
it didn't crawl past `<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
value="/wEPDwUKLTc2MzAxM..." />`
the value of __VIEWSTATE is super long. every html tags below were not
crawled. thi... |
How to control Raspberry Pi PiNoIR camera via python?
Question: I have a PiNoIR camera for a Raspberry Pi (using Raspbian), and I'd like to
control it through a python script. I tried to use the `picamera` python (2.7)
library, but it doesn't work. The camera is enabled in Raspberry Pi, and it
seems to work well (as te... |
Python Flask - How to pass values from one route to another?
Question: Hi I am new to flask and I am trying to create a simple login functionality.
Users fill out their username and password (which at this point needs to match
the username and password I hardcoded) and if their credentials are approved
they are taken t... |
why can't I access the variable in my class. python
Question: I created a panel in my main class. I then wanted to create a button that goes
into the panel. I created a seperate class for the button called
panel_in_button and set main in its parameters in hopes that I could inherit
the panel in my main class and then u... |
Installing package dependencies for Scrapy
Question: So among the many packages users need to install for Scrapy, I think I'm
having trouble with pyOpenSSL.
When I try to get a tutorial Scrapy project created, I get this following
output:
Traceback (most recent call last):
File "C:\Python27\lib\ru... |
Python comparing two files partially
Question: I have the two input file:
Input 1:
okay sentence
two runway
three runway
right runway
one pathway
four pathway
zero pathway
Input 2 :
okay sentence
two runway
three runway
right runway
zero pathway
one pathway
four pathway
I have used th... |
Python / Excel - Conditional cell printing with xlrd
Question: I want to print only the rows of a specifig column, let's say colmn B, so far
so good:
import xlrd
file_location = "/home/myuser/excel.xls"
workbook = xlrd.open_workbook(file_location)
sheet = workbook.sheet_by_index(0)
data =... |
Sliding Gabor Filter in python
Question: Taken from the gabor filter example from skimage calculating a gabor filter
for an image is easy:
import numpy as np
from scipy import ndimage as nd
from skimage import data
from skimage.util import img_as_float
from skimage.filter import... |
How to Parse XML like Dictonary in Python
Question: I am new to Python and I been trying to get below fnames Parsed and having
hard time doing so.
I need to parse below fNames...
{"values":
{"entries":"uri", "type":"xs:string", "unique-value":
[{"entry":1, "fName":"\/abc.txt"},
... |
Pyramid: DBSession.add(model) returns Type Error
Question: When I run the `initializedb.py` script, my tables are created fine but when I
try to insert any data, I get the following error:
TypeError: unbound method after_attach() must be called with ZopeTransactionExtension instance as first argument (go... |
Receiving "No Such Table" error while trying to access existing MySQL database using Flask and SQLAlchemy
Question: **myapp.py**
#!flask/bin/python
from flask import Flask, request, jsonify
from flask.ext.sqlalchemy import SQLAlchemy
app = Flask(__name__)
db = SQLAlchemy(app)
... |
How do you add additional files to a wheel?
Question: How do control what files are included in a wheel? It appears `MANIFEST.in`
isn't used by `python setup.py bdist_wheel`.
**UPDATE** :
I was wrong about the difference between installing from a source tarball vs a
wheel. The source distribution includes files speci... |
Can someone explain how to use the repr function to format the output?
Question: I would like the following code:
Tier0 = ['Tier', 'Weights', 'Price', 'Number of Businesses', 'Revenue']
Tier1 = ['Tier 1', 180,]
Tier2 = ['Tier 2', 300,]
Tier3 = ['Tier 3', 450,]
Tier4 = ['Tier 4', 600,]
... |
Python: How to group unsorted list of dictionary into new list
Question: I have a list like this:
table=[{'device': 'a', 'iface': 'i1'}, {'device': 'a', 'iface': 'i2'}, {'device': 'a', 'iface': 'i4'}, {'device': 'b', 'iface': 'i5'}, {'device': 'a', 'iface': 'i3'}, {'device': 'b', 'iface': 'i7'}]
I ... |
Trouble importing a module in Python
Question: I am trying to create a dungeon developing program, and I have a number of
modules I am using. I have a main module, a floor module, a room module, and a
tile module. Floors are girds of rooms which are grids of tiles. In my floor
module, I import Room so that I can store ... |
Trying to get a random line from a file, getting TypeError
Question: I am working on a python project that needs to read a random line from a text
file so I tried to insert a variable that is a random number into the
lines[].strip() function in python and got the error: `TypeError: 'int' object
has no attribute '__geti... |
how to compute a function in a list?
Question: I'm reading "A Primer on Scientific Programming with Python" book and I'm
stuck on exercise 2.26. It is said to write a function maxmin(f, a, b, n=1000)
that returns the maximum and minimum values of a mathematical function f(x)
(evaluated at n points) in the interval betw... |
Python 3.3 + pygame installation
Question: First, I am aware about the existance of a similar older thread, but honestly,
I would not ask, if I found any help there.
Being a simple coding enthusiast, I want to playback media in using python.
Since there seems to be no simple solution, a lot of people recommend pygame
... |
How to stop multiple processes from creating multiple instances of another process?
Question: I have 2 processes: Start and Status. There can be multiple Start processes
executed on the same time and there should only be 1 instance of Status
process.
On startup of the Start process, it will attempt to start Status. At... |
Getting AttributeError: type object 'Pipe1' has no attribute 'height'
Question: Hi I keep getting the error AttributeError: type object 'Pipe1' has no
attribute 'height' I was trying to create flappy bird with pygame/python. Just
a note, this isn't completed yet, just wanted to see if I had any major
errors. This is py... |
How can I search and replace a term with brackets in Python without catastrophic backtracking?
Question: I am currently trying to find terms like these (LaTeX definitions)
\def\fB{\mathfrak{B}}
and then remove the complete term `\def\fB{\mathfrak{B}}` as well as replacing
`\fB` by `\mathfrak{B}`.
... |
Python Random number frequency dictionary
Question: I am trying to make a function generates two random integers in rage 1 to 6.
And have a frequency dictionary of the sum of two integer values.
It is for simulating two dice rolling x number of times.
Here is my code and my code:
def sim():
dic... |
Testing A Docopt command-line app In Unittest?
Question: can anyone show me how can I test a cli app written in Docopt (Python)?
Someone on GitHub posted this,
import unittest
from docopt import docopt
import your.entry.point.of.sum as sum
# you can import the doc string from the sum mod... |
freeze_support bug in using scikit-learn in the Anaconda python distro?
Question: I just want to be sure this is not about my code but it needs to be fixed in
the relevant Python package. (By the way, does this look like something I can
manually patch even before the vendor ships an update?) I was using scikit-
learn-0... |
MemoryError when creating and writing
Question: I'm relatively new at coding and was working in python on taking a large
amount (~2.0 GB) of data from an output file and turning it into a readable
and sorted list. My major issue is creating a test file of that size. The
input file will be a long array that is something... |
Python loop to run for certain amount of seconds
Question: I have a while loop, and I want it to keep running through for 15 minutes. it
is currently:
while True:
#blah blah blah
(this runs through, and then restarts. I need it to continue doing this except
after 15 minutes it exits the loo... |
Kivy keyboard height
Question: For an app I'm creating in Kivy I would like to know the height of the
keyboard, so I can position the widgets accordingly. I heard plyer
(<https://github.com/kivy/plyer>) is good for cross-platform (I wish to
develop for Android and iOS (and Windows phone)), however it seems it doesn't
c... |
Extracting certain parts of an email using Python (Regex)
Question: I am trying to create a program that will import messages from a particular
folder in Outlook and then extract certain parts in the email.
The emails are of the form: Dear Mr.X,
{Lines of Text} See below.
Client: Company X
Fund: ABCD
Size:
Thanks... |
Python networks change color of nodes when using draw_network_nodes()
Question: The goal is to obtain something similar to

To define the graph I use:
import matplotlib.pyplot as plt
import networkx as nx
graph = {
'1': ... |
How to properly detect closed socket in Python
Question: I have a python script that emits an `HTTP POST` with json body which I pipe
to `netcat`and all works fine:
#!/usr/bin/python
body = "{ \"key\": \"Test\", \"value\": \"Test\" }"
print "POST /valSet HTTP/1.1\r"
print "Host: 192... |
Reading data out of an ADC (MCP3001) with python (SPI)
Question: I try to read some data from an ADC with python, but unfortunatly it doesn't
work. I hope someone has a hint for me, because my script creates only chaos-
data. But I don't see the mistake with the bits...
I've updated the script below as I'm reading 16 ... |
scapy OSError: [Errno 9] Bad file descriptor
Question: I'm using python 2.7 and scapy-2.2.0 in windows xp. I'm trying dns spoofing
and it works well in python. but when I make to .exe and execute it, I got
this error
Traceback (most recent call last):
File "dns_spoof.py", line 17, in <module>
Fil... |
How to import external library in python?
Question: Hie can anyone help me out with detailed process of downloading & importing an
external library called PyEnchant, to check a spelling of word is valid
english word or not
Answer: The official [PyEnchant
page](https://pythonhosted.org/pyenchant/download.html) asks th... |
Python change path inside submodule?
Question: I have this project structure:
- main.py
- app_a/
- __init__.py
- app.py
- stubs/
- app.py
- tests/
- test_app_a.py
in `main.py`, there is:
`from app_a.app import foo`
this works fine. However, when running in ... |
Performance issue with reading integers from a binary file at specific locations
Question: I have a file with integers stored as binary and I'm trying to extract values
at specific locations. It's one big serialized integer array for which I need
values at specific indexes. I've created the following code but its terri... |
Problems login in to a website in python
Question: I've been trying to connect python with http/https sites and I came across
urllib and urllib2. After some research I could create a website login but it
seems that I'm doing something wrong, I tried with different webpages but I
can't do it with any. There is the code ... |
How to: setting a testsuite in python
Question: I know it is a bit silly question, but using links provides below, I am still
unable to create testsuite.
I have now two test cases (there will be much more), let assume that the name
of there are:
class step1(unittest.TestCase):
def setUp(sel... |
Pandas Series Resampling: How do I get moves based on certain previous changes?
Question:
import pandas as pd
import numpy as np
import datetime as dt
# Create Column names
col_names = ['930', '931', '932', '933', '934', '935']
# Create Index datetimes
idx_names = pd.date_range(star... |
Python web-scraping error - TypeError: can't use a string pattern on a bytes-like object
Question: I want to build a web scraper. Currently, I'm learning Python. This is the
very basics!
Python Code
import urllib.request
import re
htmlfile = urllib.request.urlopen("http://basketball.realgm.... |
Syntax error in a Python library, and I'm not sure how to proceed
Question: I'm using pyramid 1.5.1 and python 3.2, and I just added quite a bit of code
and a couple libraries to my project.
On running development.ini, I'm getting the error below.
If I had to take a wild guess, I would say that this particular librar... |
Python regular expression search vs match
Question: I'm trying to use a python regular expression to match 'BrahuiHan' or
'BrahuiYourba'
>> re.search(r'((Brahui|Han|Yoruba)+\d+)', '10xBrahuiHan50_10xBrahuiYoruba50n4').groups()
('BrahuiHan50', 'Han')
this only returns one group, the first o... |
Copied django project to shared host from repo - can't find settings
Question: I setup Django successfully on my shared Bluehost account following the
tutorial below: <http://www.nyayapati.com/srao/2012/08/setup-python-2-7-and-
django-1-4-on-bluehost/>
I am now having problems with a Django project I have copied from ... |
The java printing code is working,send to printer but not print anything(java in python)
Question: i have made various research on this,plus,i'm using python,which i actually
implement java in python script.Somehow,the record is send to the printer(i
even got the message about this)but it does not print.can anyone help... |
python dynamic input, update table
Question: I wrote a program in order to dynamically update a database table but I am
getting an error. I stuffed the program with whatever I know little about.
Here's my code:
import MySQLdb
class data:
def __init__(self):
self.file123 = raw_inpu... |
Using ROS message and python to update text input field in kivy GUI
Question: I try to design a GUI to handle stepper motors via ROS, kivy and python. You
can find a minimal version of the GUI below. Actually I want to use a ROS
message to update a kivy text input field (read only). In the minimal example,
pressing the... |
Python - AttributeError: 'OnDemand' object has no attribute 'calc'
Question: Something is really happening and i couldnt resolve for a day almost
Examples are below: Trying a simple method calling from one class to another
class to figure out the problem as i have experienced the notorious problem
this morning as well... |
How to automatically document my class properties with decorators
Question: Suppose I have two classes (`A` & `B`) of which the second is derived from the
first. Further, I hide some of the properties implemented in A by writing new
implementations in B. However, the docstring I wrote for A is still valid for
B and I'm... |
Python to extract file date attributes
Question: I'm using Python on Windows7 to parse new names for records we have...My goal
is to include a date token as "..._YYYYMMDD.pdf" as described below.
From looking at the files in windows explorer 'details' view, I have confirmed
that the following gives me the `"Date Modif... |
Python, iterating through a list to perform a search
Question: I hope someone can point out where I have gone wrong. I am looking to iterate
through the 'mylist' list to grab the first entry and use that first entry as
a search string, then perform a search and gather particular information once
the string is found and... |
client server python -C++
Question: I have written simple client(C++) server(Python) communication using boost
asio and protocol buffer. I pass array back and forth . My problem when I pass
array from server ( python) to client (C++) I have only about 50 elements of
my first array on the C++ output. How to solve this p... |
Transpose pandas dataframe
Question: How do I convert a list of lists to a panda dataframe?
it is not in the form of coloumns but instead in the form of rows.
#!/usr/bin/env python
from random import randrange
import pandas
data = [[[randrange(0,100) for j in range(0, 12)] for y in... |
Write a string within a list to one cell in a CSV file. Python 2.7 Windows 7
Question: Is it possible to write a string stored into a list into a .CSV file into one
cell?
I have a folder with files and I want to write the file names onto a .csv
file.
Folder with files:
Data.txt
Data2.txt
... |
parallelization issue using python view library
Question: so i Worte some code with basic structure like this:
from numpy import *
from dataloader import loadfile
from IPython.parallel import Client
from clustering import *
data = loadfile(0)
N_CLASSES = 10
rowmax = nan... |
Python call a package submodule with variable module name
Question: How can I call a common submodule (present in various modules), selecting the
right module from a value?
Example:
Let's say I have this folder structure:
myprogram/
myprogram.py #main program
colors... |
Slicing numpy array with closed path
Question:
import numpy as np
from matplotlib.path import Path
w, h = 300, 200
mask = np.zeros((h, w))
verts = [(0, h), (w/2, 0), (w, h), (0, h)]
codes = [Path.MOVETO, Path.LINETO, Path.LINETO, Path.CLOSEPOLY]
path = Path(verts, codes)... |
Rpy2 error wac-a-mole: R_USER not defined
Question: I'm running Python (x,y) 2.7 on windows 7 32 bit and R version 3.1.0. I've
been trying to install Rpy2 and have been getting many errors. I finally found
this site which has pre-compiled python modules for windows
<http://www.lfd.uci.edu/~gohlke/pythonlibs/>, so I dow... |
Handling views with duplicate function names
Question: Is there any way, in Flask, to handle the issue of duplicate function names
for views across files? Just to be clear, I'm talking about the name of the
function, not the route defined for the function. So imagine in `file1.py`
I've got:
@app.route('/... |
Python: Using delimiter to write into specific columns of csv file
Question: I have an input text file with each line in the format
Line[X]: [AAA] [BBB] [CCC] :1234
I would like to use "**:** " as delimiter and write to each column into a
excel file. I have tried the following code but not sure if ... |
Neat way of making urllib work with python 2 and 3
Question: I'm looking for suggestions on how to combine the two code snippets so that
they work with both python 2 and 3. The goal is to make it "neat", ideally
keeping it to one line and limiting any if/else/try/except constructs.
For python 3.x
imp... |
What's the best data structure for output that's processed by Python?
Question: My client currently has text files that are output as tab delimited data and
with HTML table chunks. Their system takes these HTML table chunks and sticks
them in an HTML template file. I was looking at outputting the data as json or
xml, a... |
Python all() and bool() empty cases?
Question: when using help(all), it returns:
all(iterable)=>bool
return True if bool(x) is True for all values x in the iterable.
if the iterable is empty, return True
help(bool) returns:
bool(x) -> bool
|
| Returns True wh... |
PyInstaller Packages for kivy
Question: I have recently tried to build a package out of my
[kivy](http://kivy.org/#home) application using
[PyInstaller](http://www.pyinstaller.org/). My goal was to create a package I
can execute on my Linux (Ubuntu 14.04 64bit) and copy it to other Linux
systems as well.
I tried to ex... |
Why does simply importing a python module executes everything present in that module ?
Question: Recently I noticed that using modules was a good option to keep my python
programming tidy. For getting started, I made one module (named, oop.py) with
a single class in it, which looks like below:
#Module na... |
QWebView get response
Question: I have a python code with PySide that has a QWebView that shows google maps. I
just want to get the response each time that I do any request using the
QWebView widget.
I have searched info but there is no reference about getting a response with
PySide. If you need me to paste some code ... |
Advice on querying cloudant database based on geo in python
Question: Cloudant Geo Inconsistencies
I am new to IBM Cloudant CouchDB and would like to be able to query records
that I have uploaded and tagged with GPS coords.
I would like to be able to query all records that re within 100km of a
provided location.
The... |
Is there an easy way to find which part of the code not closing the file
Question: I have a large program with large amount of code. And it s is opening the file
but not closing it.
### Question:
Is there an easy way to find out where this happening?
### More Details:
OS - Linux
Python - 2.7
Why this is importan... |
export DJANGO_SETTINGS_MODULE on windows 7
Question: I'm trying to run a pyunit unittest that depends on django project imports.
I had to export the DJANGO_SETTINGS_MOCUDLE since it wasn't set so i ran:
set DJANGO_SETTINGS_MODULE=C:/bobbapython/boon/cms.settings
Which is the path to the projectroo... |
Fit points to a Lorentzian curve and find center and half maximum bandwidth in Python
Question: I am using a python program to pull discreet values from a network analyzer.
It pulls 401 y-axis values and calculates the corresponding x-axis values, and
I wish to fit them to a lorentzian curve and find the x-axis value o... |
Fastest way to write a file with h5py
Question: First of all, I read the topic "[Fastest way to write hdf5 file with
Python?](http://stackoverflow.com/questions/5466971/fastest-way-to-write-
hdf5-file-with-python)", but it was not very helpful.
I am trying to load a file which has about 1GB (a matrix of size (70133351... |
How to generate a permutation list of lists in python
Question: I have the following data in a list of lists. This is a fuel bundle (with half
symmetry) for a nuclear reactor and each number represents a fuel pin (with
different enrichments). The higher the number the more fuel. I'm trying to
generate a large number of... |
Concatenation of All Possible Combinations of Files with Python
Question: I'll preface this by admitting I'm very new to Python. I have a directory of
files that I would like to see all the possible combinations. I've located a
script that can concatenate one set list of files but I would like to see all
the possible c... |
python elementtree - getting average
Question: Using element tree in python, I want to get an average value.
Below is my data
Order A has a quantity of 12,10,and 5.. total is 27
Order B has a quantity of 9 and 40... total is 49
Order C has a quantity of 10,35, and 15.. total is 60
When y... |
Multiprocessing Error when Downloading files from FTP
Question: I have been stuck on this particular beauty of a code for a while and I can
figure out why it isn't working. When I run the code below I get a pickling
error and it is always on a different file.
This will download a random number of files and then magica... |
You are using an unsupported command-line flag: --ignore-certificate-errors. Stability and security will suffer
Question: I am getting this error in multiple Selenium Python projects when chromedriver
loads. They all start with these imports in case a specific library of
selenium...
from selenium import ... |
ImportError at / No module named response with django appengine
Question: I am trying to run django project with appengine . It is running properly on
localhost. But when I tried to upload it to appspot.com it is giving me the
following error
ImportError at /
No module named response
Here is [t... |
Simpler way of sorting list of lists indexed by one list in Python
Question: I want to sort a list of two lists, where the elements in the two lists are
pairs.
I want to sort the lists by the second element in these pairs.
For example if I have
a_list = [[51132, 55274, 58132], [190, 140, 180]]
an... |
Python - login to website using requests
Question: I have to admit I am complitely clueless about this: I need to login to this
site <https://segreteriaonline.unisi.it/Home.do> and then perform some
actions. Problem is I cannot find the form to use in the source of the
webpage, and I basically have never tried to login... |
Check OptionMenu selection and update GUI
Question: I'm working on a class project and I'm trying to take it beyond the
requirements a little here (I'm doing my own homework, just need help
improving it!) so I want to update the GUI based on certain selections the
user makes instead of just having all irrelevent option... |
Python copy and rename many small csv files based on selected characters within the files
Question: I'm not a programmer; I'm a pilot who has done just a little bit of scripting
in a past life, so I'm completely non-current at this. I have searched the
forum and found somewhat similar problems that, with more expertise... |
Google App Engine: Modifying 1000 entities
Question: I have about 1000 user account entities like this:
class UserAccount(ndb.Model):
email = ndb.StringProperty()
Some of these email values contain uppercase letters like
[email protected]_. I want to select all the `email` values fr... |
QComboBox with autocompletion works in PyQt4 but not in PySide
Question: I've got a combo box with a custom completer that worked fine in PyQt4, but
isn't working in PySide.
I have verified that the new completer is replacing the QComboBox's built in
completer because inline completion is no longer occurring. However ... |
Capture python print statements in C#
Question: I am writing a C# component which takes an ironpython function as a parameter.
def test():
x=x+1
print "Test"
C#:
var v = engine.Operations.Invoke(scope.GetVariable("test"));
Var `v` returns `null` ... |
Python Tkinter socket.recv not receiving
Question: I am trying to make a chat program with Python Tkinter, but my recv function
_recvMSG()_ either doesn't receive anything or just doesn't print anything.
Could you help me fix the receiving problem? Change the code anyway you want.
from Tkinter import *
... |
Multiple python threads writing to different records in same list simultaneously - is this ok?
Question: I am trying to fix a bug where multiple threads are writing to a list in
memory. Right now I have a thread lock and am occasionally running into
problems that are related to the work being done in the threads.
I wa... |
make python wait for stored procedure to finish executing
Question: I have a python script that uses pyodbc to call an MSSQL stored procedure,
like so:
cursor.execute("exec MyProcedure @param1 = '" + myparam + "'")
I call this stored procedure inside a loop, and I notice that sometimes, the
procedu... |
Generating SSH keypair with paramiko in Python
Question: I am trying to generate a SSH key pair with the python module paramiko. There
doesn't seem to be much info about key generation. I've read through the
paramiko docs but can't figure out whats wrong. I can generate a private and
public key without password encrypt... |
Detect simultaneous left and right clicks in python gui
Question: Tried doing some searches but was not able to get the answer however if this
has been asked before kindly direct me to that post.
I have a button in python and would want to bind that button to a leftClick,
rightClick and bothClick functions. bothClick ... |
Keyerror in python despite having keyword
Question: I am getting `KeyError:'Fellow'` after running following program despite this
keyword exist in the `text4`.
import nltk;
from nltk.book import *
cnt = {}
for word in text4:
cnt[word] += 1
print cnt['citizen']
... |
Cannot get results to display in python app
Question: What I am trying to do is write a program that reads the numbers in a text
file, displays the numbers and then displays the total of all the numbers in
the file and lists the numbers in the file
'''
This program should total the random numbers you... |
Elasticsearch Python API
Question: I am trying to use Python API "pyes" to handel elasticsearch but I could not
get it up the first time, i am running the following code:
import pyes
conn = pyes.ES('127.0.0.1:9200')
conn.indices.create_index("test-index")
And getting the following error:
... |
Search for Windows-1252 characters using Python
Question: I'm attempting to find, and subsequently replace a few Windows-1252 characters
with friendlier versions using Python. Specifically, I'd like to replace "µ"
and "³" but I can't even naively match the characters. For instance:
with open(my_file) as ... |
SQLAlchemy 0.9.4 filtering for a group
Question: I am using SQLAlchemy 0.9.4 with Python 3.4.1 and MySQL on a CentOS Server. I
am trying to filter by seeing if a certain value in a column is any of
multiple values. For example, if x in [1, 2, 3, 4, 5] I would like the value
to be selected. How could I go about doing th... |
Python List Comprehension Personal Challenge
Question: > Given a text file, "words.txt", use list comprehension to read in all of the
> words in the file, and find all the words that contain at least 2 vowels.
So, I have a text file:
The quick brown fox jumps over the lazy dog
And, the best attemp... |
pygit2 / libgit2 AttributeError: '_pygit2.Reference' object has no attribute 'oid'
Question: I am trying to create a repository and commit a file to it, but getting the
error AttributeError: '_pygit2.Reference' object has no attribute 'oid'
Any advice welcomed.
(venv3.4.1) ubuntu@app:/var/www/app-/src/t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.