Tagged Questions
Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.
1
vote
0answers
11 views
Python rss to html script version two
I wrote this script that downloads an RSS feed and converts it to HTML.
One of my only concerns is my variable naming because i suck at naming things.
Also i would like to use ...
5
votes
3answers
64 views
Python implementation of stack to return minimum in O(1) time
I have written a stack in Python that is required to push, pop and return the minimum of the stack in \$O(1)\$ time.
...
0
votes
0answers
14 views
Puzzle 8 Resolver in Python - I can't find frontier neighbors correctly and quickly [on hold]
I have to do a 8 puzzle resolver with bfs, dfs and A* algorithms in python, but I have some issue(s).
This is my output for python driver_3.py bfs 1,2,5,3,4,0,6,7,8:...
1
vote
1answer
27 views
Output a flight schedule, formatted in military time
I have a CVRP problem that I solved in Python. There are 6 planes (T1-T6) and 3 airports (AUS,DAL,HOU). The airports have 1,2,3 gates respectively. Each airport has a minimum ground time of 25, 30, 35 ...
0
votes
0answers
9 views
Set an attribute to change an objects behavior, at specific times and for a specific period
I have a program which I require to cease some of it's activities at specific times. This can change day-to-day, week-to-week.
The code below (working) is a test script. My program would check use ...
2
votes
1answer
18 views
Converting string to a set of integers
So I get a user input of a lot of numbers in a single line like this
100 100 200 300 300 300 400 500 500 700.
I want to store the distinct ones in a list.
A ...
2
votes
1answer
42 views
python recursive regex optimization
I parse a big source code directory (100k files). I traverse every line in every file and look for function calls via regex matching.
I know that using regex to parse languages is a terrible idea. ...
2
votes
2answers
28 views
Parser for Facebook friend list
I have written some code in python in combination with selenium to parse all the names from facebook friend list. It was hard to manage the pop up notification and the process of scrolling to the end ...
4
votes
3answers
56 views
4
votes
1answer
53 views
Parsing a file using PyParsing
I'm trying to parse a file of about 200 MB in size. I decided to use Python re module for this task. However, upon some further study, I found that the BNF grammar-based PyParsing provides what I'm ...
0
votes
0answers
29 views
Bi grams creating and counting of the probability of the word occurrence [on hold]
I am trying to build a bigram model and to calculate the probability of word occurence. I should:
Select an appropriate data structure to store bigrams.
Increment counts for a combination of word ...
9
votes
2answers
436 views
Printing a calendar for a month based on user input
I have a long piece of code that has many repeating points. I am sure that it doesn't take this amount of code to create a simple calendar, but I do not know how to shorten this piece of code.
...
0
votes
0answers
39 views
Find every two vowels inbetween a consonant [on hold]
Task
You are given a string . It consists of alphanumeric characters, spaces and symbols(+,-).
Your task is to find all the substrings of that contains or more vowels.
Also, these ...
3
votes
1answer
42 views
MySQL queries with try-except error handling
I have this function that I have written, that gets passed a row of data from a mysql function. The function then uses a try-except block to get some a list of values depending on a value within the ...
5
votes
1answer
468 views
Choose random instants in a day with a low memory footprint
I'm looking for a way to plan a list of X events at the start of the day...
What I did before:
At 02:00 every day, choose X timestamps from "now" to 01:59 the next day.
That worked well but I had to ...
0
votes
0answers
11 views
testing arbitrary backend implementations dynamically using py.test parametrized tests
trying to write a bunch of tests for a program that supports loading an arbitrary backend implementation dynamically using py.test parametrized tests, and it was a bit more complicated than I expected....
1
vote
0answers
12 views
Create Django objects on the fly. Better way to do it? And is the view the best place?
I have a model Sachbearbeiter that has a OneToOneField to the User model in ...
6
votes
1answer
46 views
Python 3.x Hexdump
I posted a small hexdump generator function from a program I've been writing not long ago and applied what a reviewer suggested since then. The goal was to lazily hexdump bytes objects (byte strings, ...
4
votes
2answers
57 views
MySQL parser written in Python3
As the title suggests, I'm building a MySQL parser in python. The intention of this is to better support application development by managing migrations in a more declarative way. You can read about ...
3
votes
1answer
42 views
Scraper for parsing email-ID using email sending button
I've written a script in python with POST request which is able to send email using send button and then catch the response of that email and finally parse the ID from that. I don't know whether the ...
4
votes
1answer
62 views
Scraping the full content from a lazy-loading webpage
I've written a script in python in combination with selenium which is able to scrape 1000 links from a webpage in which lazy-loading method is applied for that reason it displays it's content 20 at a ...
44
votes
4answers
8k views
Send a tweet to ISP when internet speed drops
I have written an app in Python 3 which monitors internet speed and will send a tweet to an ISP when the speed drops too low. The app has a config file where the ISP and target speeds can be ...
8
votes
3answers
95 views
Procedural style Rock Paper Scissors game using Python 3
I am a newbie to Python and am trying to do the Rock, Paper and Scissors game to revise my knowledge that I have earned so far.
Overview of the program:
This is a two-player game
Ask for player ...
3
votes
1answer
107 views
GUI Application for counting visitors
This code was to create how many people enter the "building" so there will be someone clicking the button "count". I am still improving. Please let me know your honest opinions!
...
1
vote
0answers
20 views
Go through a directory, remove [on hold]
There is a directory from an old machine I want to pick through to find useful files. But I don't want to deal with dups, of which there are many. Directories of old stuff have been snowballing from ...
3
votes
2answers
73 views
Sum of proper divisors of every number up to N
I wrote a function which provides the sum of proper divisors of every number up-to N (N is a natural number) and I want to improve its performance.
For example, if N = 10 then the output is:
...
3
votes
2answers
47 views
Sum array values based on conditions in other arrays
I have the following code that sums the values in wgt_dif (a numpy array) if certain conditions in two other ...
6
votes
4answers
79 views
Get 10-day forecast script
I coded a script to print a 10-day forecast for any location to my terminal.
As I am just learning Python (coming from the PHP world - yes, I know...) and have no buddies coding in Python, I would ...
8
votes
3answers
581 views
Dictionary of dictionary - Get 2nd keys
I have a dictionary of dictionary such as d below, and I would like to get the list of all keys but not on the first level (i.e. ...
-1
votes
0answers
25 views
Split a row into multiple cells and keep the maximum value of second value for each gene [on hold]
I am new to Python and I prepared a script that will modify the following csv file https://drive.google.com/open?id=0B2ynoLlCACXzSElFZ2poNllmVjg
accordingly:
1) Each row that contains multiple Gene ...
5
votes
1answer
31 views
Creating ICS calendar events from JSON-like file
the purpose of this code is to take a Taskwarrior (it's a todo list application) server file that is mostly JSON and create unique ICS calendar events. The logic mostly works: I still see some ...
3
votes
1answer
43 views
JSON Cache Program
I have some code that is intended to be a package (so that it can be accessed via import cachejson).
Here is the code for the package:
The update variable is ...
0
votes
0answers
13 views
Python will not show program exectuion [on hold]
I am new to python and I am trying to make a lotto game and when I run the project nothing appears in the terminal it just says press any key to continue. Is there a reason the main function will not ...
5
votes
0answers
50 views
Starting MD5 hash like Pi
I found a problem on here that ask to find an MD5 hash whose hexdigits starts like decimal digits of Pi. Is there a faster program or method to solve this than my program? This uses brute force search....
4
votes
2answers
96 views
BMI Calculator using Python 3
I am creating a simple BMI Calculator to check if the user is overweight or not. I am not sure how much improvement I need but I do appreciate any comments as to whether the coding is inconsistent.
<...
5
votes
0answers
23 views
Find videos by location
I have the following method. It has some blocks like init (raven_client, search_service), try_except, ...
1
vote
2answers
16 views
Checking directories for .pgp files
This script checks specific directories for *.pgp files. It returns a list of the filenames and modified dates. It then returns a list of the filenames and modified dates, each on a new line. I'm new ...
2
votes
1answer
59 views
“The Story of a Tree” solved using depth-first search
Found this problem in hackerrank.
One day Bob drew a tree, with \$n\$ nodes and \$n-1\$ edges on a piece of paper. He soon discovered that parent of a node depends on the root of the tree. The ...
1
vote
0answers
11 views
Using deferToThread in Twisted to run multiple tasks
I have a list of strings and for each string in the list I need to do some processing work.
The selection of strings isn't just using a for loop. Instead, in my case I need to pick up the strings ...
0
votes
0answers
17 views
Team Roster. Manages Player names, phone numbers, and jersey numbers [closed]
Note: This is written using Python 3.+
I am having issues with my add function repeating the prompts to the user repeatedly. Not sure if it is doing it for removing or editing new players, but I ...
1
vote
0answers
27 views
Efficient backend for finding nearby properties
I am thinking of building an app based on location for finding nearby properties around 15 km from the location of the user. I am a beginner in Django and for such use case I could code the following ...
2
votes
0answers
26 views
Python Tic Tac Toe Gui and AI
So, I've tried to write a gui for Tic Tac Toe or noughts and crosses, as well as an AI opponent to play against. This is by far the longest program I've written, having mainly just done bash scripts ...
3
votes
1answer
41 views
Retrieve a number in a webpage and store in a SQLite3 db
I'm beggining Python. So I wrote a program which is supposed to get a number of connected people on a forum (like this one : http://www.jeuxvideo.com/forums/0-51-0-1-0-1-0-blabla-18-25-ans.htm) and ...
7
votes
1answer
125 views
2048 game - AI can't score more than 256 average
I'm trying to implement AI for 2048 with MiniMax and Alpha-Beta pruning, based on a snake strategy, which seems to be the best as a single heuristics.
Unfortunately, AI makes 256 in most games, what ...
2
votes
1answer
105 views
Project Euler 46: Finding a counterexample to a Goldbach conjecture
I'm working on problem 46 from project euler:
It was proposed by Christian Goldbach that every odd composite number
can be written as the sum of a prime and twice a square.
...
0
votes
0answers
21 views
API error handling in Flask
I am refactoring a Flask application and, more precisely, the error handling. I am wondering if it makes sense to refactor all app.errorhandler() to a generic one.
So currently I have passed from ...
5
votes
1answer
89 views
Calculate probability of word occurence
I am pretty new in Python and I am not sure if I did everything right in my program. May someone to check it, please. Thank you!
First of all, I have a text file, for example, ...
3
votes
0answers
35 views
Functional Merge Sort in Python with only boolean variables to control fall off logic
Merge Sort
I have just implemented this merge_sort, and this is also my first algorithm implemented in Python, I am totally open to feedback about how to better use python.
I am using Arrays instead ...
2
votes
1answer
36 views
Union and intersection of two arrays
Problem:
Write an algorithm, to find the union and intersection sorted in ascending order, between the elements of two arrays
Input Format
The first line contains an integer, n1 , ...
2
votes
1answer
40 views
Find the longest sequence
Problem:
Find the longest sequence consisting only of 0's, and the longest sequence consisting only of 1's?
Solution:
...