0
votes
1answer
8 views

ipython not producing output graph using matplotlib

SO I have recently started trying to use ipython, I am finding I cannot get it to produce an output graph. I am running the following code in ipython: from sklearn import linear_model regr = ...
0
votes
1answer
12 views

Why is the result of a subclass of datetime minus timedelta a datetime object?

I've the following code: from datetime import datetime, timedelta class MyDate(datetime): pass d = MyDate.now() t = timedelta(1, 1, 1) print type(d) print type(d - t) The output is the ...
0
votes
2answers
41 views

Multiple 'or' on while loop

Hi, I'm a python newbie so please be easy on me :) Let's say I have: while input != 'n' or input != 'r' or input != 'e': is there a way to shorten that statement?
0
votes
1answer
16 views

Django - 403 Forbidden - CSRF token missing or incorrect

I'm updated to Django 1.6 and get a issue with CSRF token, when i press button "Logout". My code: --views.py @login_required(login_url='/login/') def show_matches(request): errors = [] ...
0
votes
1answer
18 views

Run Python Selenium Tests Headless

I'm having a little trouble getting Webdriver to run on a specific hub headless with Pyvirtualdisplay. The following generic code works fine: class TestHub4444TestClass01(unittest.TestCase): def ...
1
vote
3answers
50 views

Reassigning a value returned from a function in Python

My title might be a bit off but I didn't really know how to formulate myself. Say I have a function that takes a data structure and maybe some other arguments and returns a value from that data ...
0
votes
4answers
69 views

Bank account Classes. How to make it more powerful/efficient? (OOP)

I want to make this program work without using global variables. Basically, if the person withdraws and ends up going in negative figures, they incur a penalty of 5. Every transaction that's in minus ...
1
vote
3answers
20 views

Python: import module from another directory at the same level in project hierarchy

I've seen all sorts of examples and other similar questions, but I can't seem to find an example that exactly matches my scenario. I feel like a total goon asking this because there are so many ...
0
votes
2answers
41 views

python module importing difficulties

Im relatively new to python so forgive me if this is fundamental. I have a directory where I have my main applicatino code , in a file app.py . I then have a sub directory Model which contains the ...
4
votes
0answers
49 views

Finding which packages support Python 3.x vs 2.7.x

Are there any methods for automatically finding which Python versions are supported by packages on PIP? I am looking for something that generates a table like the one below obtained automatically ...
0
votes
1answer
14 views

ystockquote.get_historical_prices cannot handle dynamic dates

I'm trying to build a portfolio management program, using ystockquote. I can scrape prices using ystockquote.get_historical_prices(y, '2013-11-01', '2013-11-11') where y loops through a list of ...
10
votes
2answers
66 views

No module named 'x' when reloading with os.execl()

I have a python script that is using the following to restart: python = sys.executable os.execl(python, python, * sys.argv) Most the time this works fine, but occasionally the restart fails with a ...
0
votes
1answer
12 views

How do I bind wx.CLOSE_BOX to a function?

Fairly simple question, but I can't seem to find the answer. I have a GUI which has a cancel button that asks the user to abort all unsaved changes when they press it. The GUI also has a ...
0
votes
3answers
34 views

How to call in a specifc csv field value in python

I am so new to python (a week in) so I hope I ask this question properly. I have imported a grade sheet in csv format into python 2.7. The first column is the name of the student and the column ...
2
votes
2answers
49 views

Mysterious IndexError - very basic issue (Python)

I'm having a problem with a bit of code, I feel like I must be missing something fundamental here. A simple example that gives the same error as I am having is as follows: from numpy import ...
0
votes
1answer
23 views

Python: Return hash values from hash table regarding to a searching keyword

I'm new to python. I'm learning to get data from hash table which is stored in a file. I want to retrieve key and values regarding an input keyword. This should be return as dictionary. This is an ...
1
vote
1answer
35 views

Pattern Copying of a file Using Python

I have a file which has content as follows abcdef ghijkl mnopqr stuvwx I want to place this content into another file which should look like ab cd ef gh ij kl mn op qr st uv wx How do I do it ...
0
votes
1answer
27 views

process spawning in python

I want to use os.spawn* function to make a upstart service call. The reason to use os.spawn over subprocess is because os.spawn calls provides more control over the way the program is launched though ...
0
votes
2answers
24 views

Detect if image is color, grayscale or black and white with Python/PIL

I extract pages images from a PDF file in jpeg format and I need to determine if each image is much more grayscale, color ou black and white (with a tolerance factor). I have found some ways to work ...
0
votes
2answers
41 views

Set the name of dictionary in Python

I have a dictionary of unknown size, with keys=integers and value=strings. I need to create a dictionary for every entry. Moreover I need the values of the previous dictionary to be the names of the ...
2
votes
1answer
20 views

Scrape table without no class BS4 python

I have the following code trying to scrape data from a table which has no class from a webpage having many other unnecessary tables. from bs4 import BeautifulSoup import urllib2 import re wiki = ...
1
vote
2answers
27 views

what does the term 'bound' means in class method

When we instantiate a class, the methods get 'bound' to that particular instance for every instance created. What does the word 'bound' means here. I don't think a duplicate copy of the method object ...
2
votes
2answers
55 views

Partially unpack parameters in python

I know in Python we can unpack parameters from a tuple or list: def add(x,y,z): return x + y + z xyz = (1,2,3) s = add(*xyz) But what is the proper way to accomplish something like this: xy = ...
0
votes
1answer
10 views

MySQL-python installation - wrong architecture - MacOS

yesterday I've installed new version of python 2.7.5 via installer on MacOS and unfortunately MySQL broke down. I got following error when starting development server: raise ...
1
vote
1answer
27 views

Convert one row of a pandas dataframe into multiple rows

I want to turn this: age id val 0 99 1 0.3 1 99 2 0.5 2 99 3 0.1 Into this: age id val 0 25 1 0.3 1 50 1 0.3 2 75 1 0.3 3 25 2 0.5 4 50 2 0.5 5 ...
0
votes
1answer
31 views

certain lines to print

all_courses=open("E:/we/aa.txt","r").readlines() completed_ones=open("E:/we/aaa.txt","r") read_completed_ones=completed_ones.readlines() for ankosh in read_completed_ones: the_big=ankosh for ...
0
votes
0answers
12 views

wx python reset frame mask

I am trying to change the image of a wx frame that has a mask on it. The mask works fine, and the frame works fine, until I change the image. The old mask outline is still applying to the new image. I ...
0
votes
1answer
21 views

canvas.delete(ALL) not working

I'm currently making the graphical portion of a poker game in Tkinter with Python 2.7, but I'm having trouble with redrawing the canvas at the moment. For some reason self.canvas.delete(ALL) won't ...
0
votes
2answers
24 views

Installing PIL with pip

I am trying to install PIL (the Python Imaging Library) using the command: sudo pip install pil but I get the following message: Downloading/unpacking PIL You are installing a potentially ...
-1
votes
2answers
45 views

how to create a matrix for the number 0 in this code?

Hi guys, I have a homework assignment to draw pyramids of a given height. Below are examples for height = 2 and height = 3: ..... ..... ..... ..... ..... ..x.. ..X.. ...
0
votes
2answers
35 views

Summarise data by using index i

Codes: for i, words in enumerate(list): syn = eachscore(num) for score in syn: count = count + 1 sscore = str(score).split() first = sscore[2] second = ...
-1
votes
4answers
39 views

Get module handle to Popen

I'm trying to take the assigned object from an open Popen object, then assign it to something global in the module so that I can query it from my main function. sort of like this: class ...
0
votes
1answer
30 views

How do I use objects imported from a module?

I am having a problem using a class from a module. module: http://pastebin.com/A3UQ2Ppy def ClassName(object) def __init__(self, var): self.var = var def method(self): print ...
0
votes
0answers
27 views

Python — Matplotlib return a plot based on user mouse-input

This class sets the P and Q and P+Q=R of an elliptic curve. However, the inputs for a,b, and the others are set in main(). I'd like to set them as user-driven from mouse interaction. So, the user ...
-2
votes
1answer
56 views

Error “invalid literal for int() with base 10: '['”

I am trying to find the digital sum of a number by using loop I created a helper function, to make the number into a list. however, I keep getting invalid literal for int() with base 10: '[' as the ...
0
votes
1answer
54 views

Simple Tic-Tac-Toe in python 2.7

I'm trying to create a simple tic-tac-toe game for a class project, but I'm not exactly sure how to go about finishing the rest of the code. I'd really appreciate any insight or input as to how I can ...
1
vote
4answers
68 views

Using 'not in' and 'or' in a while loop

I'm trying to use a while loop to make sure an input is one I want. This bit of code is an example of what I'm trying to do. Is there any way to make this work? Thank you. ...
1
vote
3answers
40 views

printing double quotes around a variable

For instance, we have: word = 'Some Random Word' print '"' + word + '"' is there a better way to print double quotes around a variable?
1
vote
1answer
37 views

Creating an iterated json file in python?

Currently I'm using: import json jsonlist = ["data", "test", "row", "blah", "boo"] with open('test.txt', "wb") as jsfile: jsfile.write(json.dumps(jsonlist)) My current output is: ["data", ...
0
votes
2answers
65 views

Deleting nth element from a list Python 2.7

I haven been set this task below: You are the captain of a sailing vessel and you and your crew have been captured by pirates. The pirate captain has all of you standing in a circle on the deck of ...
0
votes
2answers
34 views

UnboundLocalError: local variable 'ext' referenced before assignment

I'm new to programming and Python--perfect storm... Despite being long, this is only a snippet of over 1300 lines of original code. What I'm adding is the ability to split filenames into root.ext ...
1
vote
1answer
21 views

Difference between log(dataframe) in IPython and in execution

I have a pandas data frame as an attribute in Python 2.7, called probs. If I try to execute log(self.prob['AAA']) (where AAA is a valid name for one of the columns in the data frame), I get the ...
0
votes
2answers
30 views

django-tables2: create a input text box

I would like to create a table with multiple columns that display existing data, and one column that contains a text box where I can input data. When I use my "Animal" model in my forms.py, I see ...
-1
votes
0answers
37 views

Executing ./script.py and python script.py - django

I want to run custom lib in my django app. When I run it in normal python script using command: python test.py it works. If I use ./test.py command it doesn't work and I get following error: ...
0
votes
1answer
16 views

How to get the ipython notebook title associated with the currently running ipython kernel

I usually have 5-10 different ipython notebooks running with associated consoles/kernels. It is hard for me to keep track of which console/kernel belongs to which notebook. For a while I put a ...
0
votes
1answer
20 views

Apache: How to set default document to a python script?

I have apache running on a Raspberry Pi. My website is using running Python scripts. How do I make, say, start.py, as the default document for the site? In other words, if the host name for the ...
0
votes
1answer
16 views

Logging on mpi4py child files

I am using mpi4py to distribute work to different files. Does anyone know how I can include logging information of these child processes into my log-file. I call my child processes in the following ...
1
vote
3answers
74 views

Why is popping from a list time consuming as compared to appending?

I was making a simple function to rearrange a list with very large no of elements say 100,000 or probably 1 million. Here is the code of the function def Rearrange(): global list1 ...
1
vote
1answer
29 views

How to get redirected URL without downloading file

I'm writing a web scraper and basically what I'm working with using requests and bs4 is a site that provides all content in the style https://downlaod.domain.com/xid_39428423_1 which then redirects ...
1
vote
0answers
9 views

Popen xauth list

I am trying to run a wxpython script via VNC. When i try to open it i get the error: X11 connection rejected because of wrong authentication. Unable to access the X Display, is $DISPLAY set properly? ...

15 30 50 per page