Tagged Questions
0
votes
0answers
9 views
Blender3D - Installing along side python 2.7 win7 64bit
I'm interested in doing some work in Blender3D, but the latest release won't run and I believe it is because of my current python 2.7 install, which I use due to certain modules not supporting python ...
0
votes
1answer
21 views
How to parse a large XML file in python?
I'm using python version 2.7.* and i need to get youtube playlist. I do it like this:
import urllib
from xml.dom import minidom
playlist_xml = ...
0
votes
0answers
8 views
CPUID in Python & timing it's response
I am planning on writing a python(2.7) script which can detect a virtual environment.
I know of a method which involves executing the CPUID instruction within a virtual environment and then timing ...
-1
votes
2answers
23 views
I am trying to write a program that will interleave a list which contains a pair of lists?
I am trying to write a program that will interleave a list which contains a pair of lists?
def interleave(lst):
if lst==[]:
return []
return ...
0
votes
3answers
34 views
Ubuntu 12.04 LTS: Update python 2.7.3 to 2.7.6 without breaking dependencies [on hold]
So, I recently reinstalled Precise after encountering some swap issues. A friend and I were discussing working on something in Python together, so I checked my version. However, 12.04 comes with ...
0
votes
1answer
38 views
Python “variable not defined” error when it is
Below is the code I have been working on. I am new to python and programing and have been trying to teach myself.
I get the following error. But messages is defined so I don't understand.
...
-1
votes
1answer
39 views
Python Invalid Snytax
Below is the code I have been working on.
The very last line write_csv('twitter_gmail.csv', messages, append=True) throws a
[ec2-user@ip-172-31-46-164 ~]$ ./twitter_test16.sh
Traceback (most recent ...
-1
votes
0answers
27 views
function that returns past tense of given verb
Any python program support to find the past tense of the given verb. I think there is no ambiguous on this question but stack overflow not allowed to post a small explanation that's why I explain the ...
1
vote
1answer
24 views
Parse CSV containing list in a column
I have a CSV file that I generated through a csv.writer object. Here is a simplified version of the code to generate the file:
output = open('out.txt', 'ab+')
writer = csv.writer(output, ...
0
votes
1answer
13 views
__init__ in GUI with tkinter
I am learning to create simple GUIs with python using Tkinter. I am currently using the python documentation as reference (link).
First thing I am trying to do is understand the sample code there. I ...
-1
votes
1answer
35 views
Adding in drops from enemies in Pygame?
I am trying to add in random drops from enemy deaths to a game I am making in Python and wondering how to implement it. the drops I am wanting to add currently are shield and health, with shield ...
0
votes
2answers
21 views
Searching for strings in a list which contain a specific word
I am writing a code in Python 2.7 in which I have defined a list of more then a million strings. Here is my simple code to find the strings that contain a keyword:
for word in wordlist:
if keyword ...
1
vote
1answer
40 views
Python 2.7.3 | Created a list and tried to append it to itself, this is the result I got, could some please explain me what's happening with it? [duplicate]
I've created a list in python,
list1 = [1,2,3,4]
and tried to append it tp itself,
list1.append(list1)
this is what i've got, it's kind of never ending!
could someone please explain me what is ...
0
votes
0answers
13 views
Installing Tweepy on OS x
I have been trying to install tweepy on OSx via
pip install tweepy
I have already installed pip, but I am getting this strange error message I haven't come accross before and, obviously Tweepy ...
0
votes
2answers
41 views
Trouble using max(list)
Im trying to use max() func to find max value in given a list.
Im creating a list for a given column from a txt file (representing a table, each line has a name and same amount of data columns).
for ...
0
votes
0answers
24 views
Displaying a pdf document within a PySide python application
I have a python application using PySide, Qt and python. In my application I would like to open and display a pdf document, but have the viewer within the application and not using the default viewer ...
0
votes
1answer
46 views
Writing into CSV file using python
Here some simple code I have written. Data is not accumulated in the CSV file;
can someone share code to read data from serial port and log this to a CSV file?
import serial
import csv
import string
...
-1
votes
2answers
26 views
Get a text file specific field issue
I am working on python in order to use data mining on social media to analysis data .
Now I have written a code which gives me information about Facebook most liked pages and I have stored ...
0
votes
1answer
25 views
ImportError: No module named scipy.linalg.blas on Mac OS
I am trying to use decaf (git clone https://github.com/UCB-ICSI-Vision-Group/decaf-release.git) which depends on scipy, but I recieve an error:
slesarev-osx-2:decaf-release slesarev$ python ...
4
votes
3answers
40 views
Strange behavior when comparing unicode objects with string objects
when comparing two strings in python, it works fine and when comparing a string object with a unicode object it fails as expected however when comparing a string object with a converted unicode ...
3
votes
2answers
22 views
Radiobutton modifying increment values in spinbox Python
I'm trying to create a GUI in Python 2.7 with Tkinter. I need that the increment value from my Spinbox changes accordingly to a value selected from a selection of Radiobutton. I've tried different ...
0
votes
1answer
10 views
Setting a try / timeout with ftplib in python?
How can I set a timeout of 10~ seconds and if it fails to upload or times out to try again?
Current code:
print "Uploading LIST{}.html".format(counter)
ftp_session = ...
0
votes
0answers
16 views
Placing text from python to windows 8 clipboard
I've searched around on stackoverflow and I can't seem to understand how you would copy a string input into the windows clipboard. So what I want to do right now is to take a string in a program in ...
0
votes
1answer
18 views
Selenium WebDriver: socket.error: Connection Reset by Peer
I am trying to run Selenium WebDriver using PhantomJS.
Whenever I try execute:
from selenium import webdriver
x = webdriver.PhantomJS()
x.get('any address')
I get the following error message:
...
1
vote
2answers
84 views
Is there a more Pythonic way to test if an object is a number or return its value? [duplicate]
I have not tried decorators yet or functions within functions, but this current un-pythonic method seems a little convoluted. I dont like how I need to repeat myself when I check the return_type (3 ...
0
votes
0answers
23 views
Tweepy import error
I installed tweepy module using command in mac UNIX shell:
pip install tweepy
but when I try to import tweepy after running python, it returns:
ImportError: No module named tweepy
Any ideas ...
0
votes
3answers
31 views
Remove certain type of tag from HTML (without string operations) with Python and BeautifulSoup [on hold]
I have a long html file, and it has a bunch of "span" elements throughout. (Ie they begin with <span and end with /span>. Is there a way with BeautifulSoup to eliminate all of those span ...
1
vote
2answers
30 views
Basic Matplotlib Scatter Plot From Pandas DataFrame
How to make a basic scatter plot of column in a DataFrame vs the index of that DataFrame? Im using python 2.7.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
...
1
vote
2answers
25 views
Parse HTML with Python and BeautifulSoup - get text both inside and outside the <a> tags
I have html with a number of tags, and then text which is outside those tags. The text I'm trying to get is in tags except the first instance, which is I guess just part of the tag. But if I try ...
1
vote
1answer
46 views
Compress data in Java and decompress in Python
So I am trying to compress (gzip or similar format) a JSON object before I throw it in my MySQL database. I am currently storing the data as BLOB. I have tried to use the following Java method to ...
0
votes
1answer
34 views
Trigram count print
I wanted to print the trigram frequency of a list of text files in a folder.
This is my python code, it doesn't print anything.
Any thoughts on what changes should made ?
import nltk
import os
from ...
1
vote
4answers
38 views
Parse 'a' tags based on attribute using Python and BeautifulSoup
Using this bit of html:
<td align="left">
<a class="playerLink" href="http://bbroto.baseball.cbssports.com/players/playerpage/2000032">
Russell, Addison
</a>
...
0
votes
3answers
37 views
Pygame: Game Over Screen
Hello I am making a game in pygame and I am wondering how and what the best way is to add a game over screen. Here is the code up to where the players health is smaller or equal to 0:
import pygame
...
1
vote
0answers
18 views
UnicodeDecodeError with xlwt
I'm using python with xlwt and have a problem
My code:
tickets = cursor.fetchall ()
largo = len(tickets)
cursor.close ()
conn.close ()
row = 4
for t in tickets:
hoja.write(row, 1, t[0])
...
-1
votes
3answers
34 views
Runtime error in python:lists
why is the following code giving runtime error
please suggest the reason, cant the arrays be indexed like c++
t=input()
dp1=[]
dp3=[]
dp5=[]
dp7=[]
dp1[0]=0
dp3[0]=0
dp5[0]=0
dp7[0]=0
dp1[1]=1
...
0
votes
0answers
52 views
Python: Test a program
I want to test a python program which contains threads. I have searched for testing tools but I do not understand how to use them. For example I found the PyUnit which uses the unittest library but I ...
-3
votes
1answer
38 views
Python generator expression Twitter [on hold]
I am kinda new to working with json and python and I am stuck on the parsing the data in js to generate an expression. I would really appreciate anyone suggestions on the best path to take.
Here is ...
1
vote
2answers
22 views
How to use Beautiful Soup to select only one of multiple tables
I have an html document with 4 or 5 different tables. The one I want has an attribute class = "data". I can't figure out how to make BeautifulSoup return just that table.
soup = ...
12
votes
2answers
79 views
How do I concatenate many objects into one object using inheritence in python? (during runtime)
I have the following classes:
class hello(object):
def __init__(self):
pass
class bye(object):
def __init__(self):
pass
l = [hello, bye]
If I do the following I get an ...
1
vote
0answers
50 views
Python script runs from IDE but fails on double click in windows 7
I wrote a gui script in python to start and stop the server. I can successfully run it from my IDE but it does not load when I double-click on it in the same directory. When I open up a cmd or far to ...
2
votes
1answer
39 views
Differences in re.findall and re.finditer — bug in Python 2.7 re module?
While demonstrating Python's regex functionality, I wrote a small program to compare the return values of re.search(), re.findall() and re.finditer(). I'm aware that re.search() will only find one ...
0
votes
2answers
38 views
How do i know python path on linux ubuntu?
In ubuntu linux if we want to set up python path we do something like this:
export PYTHONPATH=/etc ...
Now, how i would know what the current path I have?
1
vote
4answers
94 views
Why is b=(a+=1) an invalid syntax in python?
If I write the following in python, I get a syntax error, why so?
a = 1
b = (a+=1)
I am using python version 2.7
what I get when I run it, the following:
>>> a = 1
>>> b = (a ...
1
vote
2answers
50 views
All slice operations return a new list?
In Python Tutorials, it is said "All slice operations return a new list containing the requested elements".
>>>a = ['spam', 'eggs', 100, 1234]
>>>a[0:2] = [1, 12]
>>> a
[1, ...
0
votes
1answer
28 views
How to use handler404 view in django?
I want to display a 404 error page when user hits a url which is not in the urls.py.
In settings.py I put DEBUG = False,and I have written a handler view like this
def handler404(request):
from ...
3
votes
1answer
35 views
How to assign IP address to interface in python?
I have python script that set the IP4 address for my wireless and wired interfaces. So far, I use subprocess command like :
subprocess.call(["ip addr add local 192.168.1.2/24 broadcast 192.168.1.255 ...
0
votes
1answer
23 views
Encrypt communication between Qt application and Python service
I have a cross-platform application in Qt5 and QML that works with Python-2.7 service through HTTP using JSON format.
I need the service to be used by my software only and no one else could use it.
...
0
votes
1answer
24 views
Using Python Requests to pass through a login/password
I have looked at related answers and I haven't found something that quite works. I'm trying to scrape some fantasy baseball information from my team's CBS Sportsline page.
I want to post the login ...
0
votes
2answers
39 views
Twitter Python Json to CSV
I am new to Python and programing in general.
I wrote this script and it runs with out error but is doesn't print any content in the .csv even though I know there is content to print. I have been ...
0
votes
2answers
47 views
Merge sort list index out of range
I'm trying to do a basic merge sort in python, but every time I run the code I get the error
"...
if x[0] < y[0]:
IndexError: list index out of range
"
And I'm not sure where I'm going wrong. ...