2D array slicing by float value in Python

I want to slice an array of [x,y] coordinate pairs by x value in Python 3.x, in a similar way to the solution to this question but with coordinates rather than a 1d list. For example for the (numpy) array of coordinates I want a function like: coo...
more »

2017-01-16 21:01 (4) Answers

Django template with multiple models

I have a template from which I need to render information from multiple models. My models.py look something like this: # models.py from django.db import models class foo(models.Model): ''' Foo content ''' class bar(models.Model): ''' Bar c...
more »

2017-01-16 19:01 (2) Answers

Django object.filter is not loading all results

I am using Django 1.10.4 and MySQL 5.7. So, I have following models: class Image(models.Model): request = models.ForeignKey(Request, on_delete=models.CASCADE) customID = models.CharField(max_length=128, null=True) status = models.Intege...
more »

2017-01-16 10:01 (1) Answers

How to check if a number is in a list of lists?

so I've been having trouble checking if the number 0 is in a group of lists within another list. These rows make up the maze for a pacman type game I'm making so the point of this is to check if pacman has eaten all of the coins. Here's my code: ro...
more »

2017-01-16 02:01 (5) Answers

Can I use Scrapy for scraping and parsing only?

I'm new to Scrapy and I've searched around, but can't seem to find any answers specifically for what I want to do. I'd like to scrape content from a pre-defined list of webpages (my growing list of bookmarks) and submit relevant content to a MySQL da...
more »

2017-01-15 23:01 (0) Answers

Last 2 digits of an integer? Python 3

With my code, I want to get the last two digits of an integer. But when I make x a positive number, it will take the first x digits, if it is a negative number, it will remove the first x digits. Code: number_of_numbers = 1 num = 9 while number_of_...
more »

2017-01-15 19:01 (3) Answers

Prefix search against half a billion strings

I have a list of 500 mil strings. The strings are alphanumeric, ASCII characters, of varying size (usually from 2-30 characters). Also, they're single words (or a combination of words without spaces like 'helloiamastring'). What I need is a fast way...
more »

2017-01-15 18:01 (3) Answers

Python 3 - complex numbers

I'm trying to write a method to generate a sequence of Gaussian divisors of a Gaussian integer - a Gaussian integer is either a normal integer or a complex number g = a + bi where a and b are both integers, and a Gaussian divisor of a Gaussian intege...
more »

2017-01-15 17:01 (1) Answers

Django static media not showing picture

after searching for a solution for hours which did not resolve my problem,I am posting this. The image from my media root is not showing up on my html. In chrome's console i get a 404 file not found.Even though the image is there. I am using Python 3...
more »

2017-01-15 12:01 (1) Answers

Python edit specific words of a text file

My program is a basic Tkinter game with a scoreboard type system. This system stores the username and the number of attempts each user has had in a text file. For example, when it is the user's first time, it appends their name to the end of the tex...
more »

2017-01-15 11:01 (2) Answers

Matrix multiplication with bitwise operators

I want to create a bitmask vector that masks which values are greater than a given value. Something like [1, 2, 3, 4, 5] * [>3, >3, >3, >3, >3] = [0, 0, 0, 1, 1]. I want to be able to run this on theano to get faster computation time for matrix opera...
more »

2017-01-14 19:01 (1) Answers

Getting different results from print and return

I'm currently developing a lambda in python and I'm actually a little bit struggling with building jsons in python. The lambda reads from a dynamodb-table and adds all returned values to a json structure. This works like a charm for printing that j...
more »

2017-01-14 17:01 (1) Answers

Pyinstaller image does not load

The Problem Im trying to turn a python file into an EXE file, however I seem to be running into the same problem every single time, whether it is CX_Freeze or Pyinstaller. I just tried using pyinstaller and I made an EXE file using the command pyin...
more »

2017-01-14 05:01 (3) Answers

Python - find longest path

The function will take in a dictionary as input, and I want to find the length of a longest path in a dictionary. Basically, if in a dictionary, key2 matches value1, and key3 matches value2, and so forth, this counts as a path. For example: {'a':'b'...
more »

2017-01-14 02:01 (2) Answers

Django app deploy to Heroku, Application Error,

I am struggling to get my Django 1.10 app deployed to Heroku. Just as a preface, I am using Pycharm and had to rename my project at one point, but it refactored and changed the name in all places so I'm hoping that's not related to the issue. When I ...
more »

2017-01-13 23:01 (1) Answers

Reading huge number of json files in Python?

This is not about reading large JSON files, instead it's about reading large number of JSON files in the most efficient way. Question I am working with last.fm dataset from the Million song dataset. The data is available as a set of JSON-encoded te...
more »

2017-01-13 16:01 (1) Answers