Python is a dynamic and strongly typed programming language that is designed to emphasize usability. Two similar but incompatible versions of Python are in widespread use (2 and 3). Please consider mentioning the version and implementation that you are using when asking a question about Python.

learn more… | top users | synonyms (3) | python jobs

0
votes
0answers
1 views

Django selectable, AutoCompleteSelectMultiple : Form not validated

I created a ModelForm with a widget of django-selectable: class SomeRequestForm(forms.ModelForm): created_by = selectable.AutoCompleteSelectMultipleField(lookup_class=SomeGroupUser, label='', ...
-1
votes
0answers
12 views

create html elements using information from a python file

How to extract information from a python script and create a html element dynamically? For example: python file like this mylist=['a','b','c'] using the content of mylist filling in a created ...
0
votes
2answers
18 views

Python; Convert Scientific Notation to Float

Encountered a problem whereby my JSON data gets printed as a scientific notation instead of a float. import urllib2 import json import sys url = ...
-3
votes
0answers
27 views

Learn how to develop applications using Python [on hold]

I have recently learnt Python, and would like to take a step ahead by developing a small application. The application would be a school records register, that would contain all the details of the ...
0
votes
0answers
8 views

background music not playing in pygame

When i run the code it play only the .wav file import pygame, sys from pygame.locals import * pygame.init() DISPLAYSURF = pygame.display.set_mode((500, 400), 0, 32) ...
-1
votes
0answers
10 views

Form through Email that can be Parsed Using Python

I want to email out a document that will be filled in by many people and emailed back to me. I will then parse the responses using Python and load them into my database. What is the best format to ...
0
votes
3answers
24 views

How Can I Call a Class Method From a Different Class in Python?

I have a Raspberry Pi with: Serial interface over Xbee to Arduinos WebSocket server interface to a Web page (html/javascript) I wrote a Python script to coordinate communication (I'm brand new to ...
0
votes
1answer
21 views

How to map a unique id (counting from 0) to items in sublists

Let's say I have a = [['a1', 'b1'], ['a1', 'b2'], ['a2', 'b1'], ['a2', 'b4']] As a result I want a = [[0, 2], [0, 3], [1, 2], [1, 4]] Give an id to the first item of every sub-list (i.e a[:][0]) ...
0
votes
1answer
16 views

FInd javascript-links with Python

Is there any way to find javascript-links on a webpage with python? I use mechanize and I can't find all the links I want. I want the url on the pictures on this site: http://500px.com/popular
-1
votes
0answers
34 views

Count how many certain lists is in list

I would like to count the occurrences of a certain list of a list and if the count is higher than 1 break the loop. Below is the code that I've written but it doesn't work. Can some one explain me ...
0
votes
1answer
17 views

Tests for views in Django application

I have few models in my models.py. Two of them are as follows: class Event(): eventName = models.CharField( unique = True ) class Job(): event = models.ForeignKey(Event) jobName = ...
1
vote
3answers
23 views

Regex Don't allow space as a last charicter

I have a python regex matcher [A-Za-z0-9_\s] How can I set it up so that it allows spaces, but doesn't allow spaces as the last character. Given the string "Monthly Report Aug 27th 2013 - New York" ...
0
votes
3answers
34 views

Cut a large text file in small files

I have a text files which contains 1000000 lines. I want to split it in files that contains 15000 lines each. E.g, first file contains 1 to 15000 lines, next file 15001 to 30000 lines and so on. This ...
0
votes
0answers
8 views

(python) OpenGL code (glGenVertexArrays) works on Linux but not on windows

I am porting my python+openGL code from my linux desktop to my windows laptop. THznks to python, I didn't have to change many things but I am now stuck. The glGenVertexArrays(1) call does not work, ...
0
votes
0answers
10 views

CX_Freeze for my python script — Fix up module error?

This is my main code: import turtle import random from sys import exit import canvasvg import os import tempfile import shutil import cairosvg red = 125 green = 70 blue = 38 pen = 15 def ...
0
votes
0answers
6 views

working with large graphml files in networkX

I have some fairly large .graphml files (~7GB) and I would like to run some algorithms on these files using NetworkX. Whenever I try to read these graphml files with: print "Reading in the ...
0
votes
0answers
3 views

how to enable connectiondraining with python boto modify_lb_attribute

I have been trying to enable ELB connection draining using the modify_lb_attribute method in the python boto module; however I haven't been able to get it working. According to the documentation here ...
0
votes
1answer
24 views

Login on a website with python, I tried many examples, but what am I doing wrong?

I know there have been plenty of examples on here that explain how to login on a website with Python, but I've been trying for the past 3 days and I didn't manage to get anything to work. This might ...
0
votes
1answer
13 views

How to default a Django DateTimeField to utcnow() + 1 day?

I have a Django object that looks like this: from datetime import timedelta class MyObject: startTime = models.DateTimeField(default=datetime.datetime.utcnow) Now I want to add a field to this ...
1
vote
1answer
7 views

Flask Restful add resource parameters

I am looking to pass an object instance as a parameter into a Flask-RESTfull Resource. Here is my setup: # in main.py from flask import Flask from flask.ext.restful import Api from bar import Bar ...
-2
votes
0answers
9 views

Need help obtaining the freebase API

I would like to start developing with the Freebase Python API, but I'm having trouble getting an API key. I have enabled the Freebase API but where do I get the key? In the new layout I can't even ...
0
votes
1answer
14 views

Scipy BLAS dot speed up issues

I am currently trying to speed up my large sparse (scipy) matrix multiplications. I have successfully linked my numpy installation with OpenBLAS and henceforth, also scipy. I have run these tests with ...
1
vote
1answer
23 views

Optimizing numpy matrix operations (currently using a for loop)

I've written some code to compute n matrices based on n items in a list, and then multiply all matrices together at the end. The code is relatively slow and I'd like to learn more about python ...
1
vote
0answers
22 views

Numpy memory error with 256GB of RAM, 64-bit python, and 64-bit numpy. ulimit issue?

There are numerous posts about numpy memory errors in google land, but I can't find one that resolves my issue. I'm running someone else's software using a high-end server with 256GB of RAM, 64-bit ...
0
votes
1answer
14 views

Python MySQLdb - do I have to close cursors and connections?

Im Python newbie. I wrote simple script which runs every minute on my Raspberry Pi and it logs some data to MySQL 5.5 database. Script looks like this: #!/usr/bin/python import MySQLdb as mdb from ...
-2
votes
2answers
35 views

Python in x for loop 0,3 use x in a variable

Just a newbie learning python. I have a list of tweets in json. Every tweet has a text, a url, an image and so on. I want to access for instance the url from tweet2 so I can use that variable to ...
-6
votes
1answer
27 views

Python code for generating Fibonacci numbers is not working

I wrote some code to generate Fibonacci numbers. Here is my code: for i in range (10): f=0 s=1 t = f + s print t f = s s = t (http://ideone.com/tLEnsi) I tried to change ...
1
vote
2answers
30 views

Python Fast Open File Only Need To Compare Bytes

bytes = "abc123" with open(file, 'rb') as in: info = struct.unpack('<H', in.read(struct.calcsize('<H')))[0] info2 = infile.read(info) if info2 == SIGNATURE: ...
0
votes
1answer
16 views

Python regex to find string which ends with A OR B, either if A comes first or B (non-greedy search)

I have the following python code data = re.sub("{.{4,9}b .*?[\r\n]*?.*? ((.*\\()|(..fs24))",string,re.DOTALL) I want to be able to have two matches for each of the strings below ?{\f1\fs24\b ...
0
votes
1answer
48 views

French regular Expression

I have a french regex, and there are accents on it. I have a printed dictionary (not the pythonic data structure) : a list of words written in uppercase followed by there definition. I want to split ...
-2
votes
0answers
14 views

Searching and inserting in Database

I am writing this python script to search for a string in a file and once that string is encountered in that file it should be able to insert a numerical value against it in a mysql db like suppose a ...
0
votes
0answers
9 views

Automatically downcast to subclass using django-model-utils

I have multiple user models .. all inheriting a Base model with a custom manager models.py class BaseUser(models.Model): [...] objects = UserManager() class StaffUser(BaseUser): ...
0
votes
0answers
6 views

ValueError: Extra data: line 2 column 1 [duplicate]

This is my code: json_obj = urllib.urlopen('http://cosminzorr.eu/hitbox/updates.php') data = json.load(json_obj) updates = int(data['updates']) and when I run it I get this error: Traceback (most ...
0
votes
2answers
19 views

finding all combinations of a list of any count [duplicate]

I am looking for a way to generate all combinations of items in a given list with an output of a given count. The inputs will be the list and the number of items in each returned combination. For ...
0
votes
0answers
8 views

how to implement pycurl

So far I got my python app to read my accounts totals for crypt currency, and now I need help with sending a HTML message to their servers. On this website https://www.eobot.com/developers they give ...
0
votes
0answers
11 views

GAE datastore group entity pro and cons

I am Modelling a database under GAE dealing with processing learners assessment. So let's say I have this: class Assesment(db.Model): usrId= db.StringProperty(required=True) subjectID= ...
-1
votes
0answers
6 views

Beautifulsoup caracter encoding issue

When i try to parse some html with quotes like this "d’un" beautifulsoup turns it like this "dun" why? and what's the solution?
0
votes
0answers
10 views

Cannot read compressed bz2 file from http://archive.routeviews.org/

For class we are to download these 54MB .bz2 files from routeviews. When I unzip the .bz2 files they are in .0000 format and around 500MB. When I -tail -f the output its a bunch of garbage. How can ...
1
vote
0answers
8 views

mpi4py send and receive by the same process

I have n processes and they communicate with each other. There are also situations when a process sends the message to itself. I am using mpi4py python module to model this, but it seems that sending ...
-2
votes
2answers
29 views

Python Prime Number Program Bug

I am trying to make as a challenge a program that can perform different tasks relating to prime numbers. One of these tasks is saying wheather a number you enter is a prime number (this is option A in ...
0
votes
2answers
19 views

Python Blackjack Game how to carry a variable in a while loop

I'm still deep into the making of my Blackjack game in Python, my aim is to allow the computer to 'twist' (Take another card) until the total value is greater than 15. From then onwards I want it so ...
0
votes
3answers
36 views

sorting dictionary in a list by value with unicode

I'm practicing my beautifulsoup/web scraping and have been looking at option data. So far I have the information in a list of dictionaries. I'm trying to sort my output by Open (in descending order) ...
1
vote
0answers
26 views

Python Regex Partial Match or “hitEnd”

I'm writing a scanner, so I'm matching an arbitrary string against a list of regex rules. It would be useful if I could emulate the Java "hitEnd" functionality of knowing not just when the regular ...
0
votes
3answers
27 views

Stuck on Combining Functions, D.R.Y

I've been learning python for the last 10 mos. or so and I'm running programs which update objects in Salesforce. The fact that it's salesforce really doesn't matter. What matters is that there are ...
0
votes
1answer
11 views

ImportError: works on osx not on ubuntu

I have a strange import problem with python. The same code works on OSX, but it doesn't work on precise 12.04. test.py lib/ twitter/ twitterstream.py __init__.py The twitterstream.py ...
0
votes
0answers
13 views

Flask debug true not taking effect (OS X Yosemite)

I follow the instructions from: The run() method is nice to start a local development server, but you would have to restart it manually after each change to your code. That is not very nice and ...
1
vote
0answers
16 views

Z3py - Create Z3py expression from string, or: What happens with 'not' in eval?

I am trying to solve constraints in an if or while statement by using Z3py. As Z3py expects expressions like True, False or Z3py-Boolean expression, I had to work out how I can convert the constraints ...
0
votes
0answers
28 views

How to get a pointer to raw binary data in Python?

I'd like to get a pointer to raw binary data of bytes, bytearray, or memoryview instance via ctypes and Python API. For reading, (c_char * len(b)).from_buffer(b) works in Python 3. For writing, I ...
0
votes
1answer
14 views

Python Flask outgoing post request is converted to GET using Passenger WSGI

I had this issue yesterday and investigating with help I've come across with this problem. Flask is not getting any POST data from a request So to sum up (you can see more details on my other post): ...
0
votes
2answers
36 views

how python system call returns?

I have a probably naive question regarding python system call behavior. I am wondering if os.system() will return right away after the cmd is called or it will wait any the cmd finish to return. ...