Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.

learn more… | top users | synonyms

0
votes
0answers
5 views

Overall utility tool for a project that will create account lists for pulls

I'm creating a meta-utility tool for a project that I'm on that has a lot of repetitive tasks that can eat up a lot of time. My goal with this tool is to eventually be able to automate, or at least ...
4
votes
2answers
49 views

Searching within multiple objects of the bucket

I have millions of files in the Google cloud storage's bucket. I want to search within files with a .index extension and retrieve the contents. This is currently what I am doing, but the time ...
3
votes
4answers
116 views

Find the locally biggest or equal values including corners in an array

I am looking for a function, that will find in array of n integers highest or equal locally values including corners. My code is probably wrong, and I somehow think solution is in some library like ...
0
votes
0answers
24 views
4
votes
1answer
51 views

Reddit bot to check reposts

I am a moderator of /r/sweepstakes on Reddit, which lets users post their referral links to contests/sweepstakes. One main rule is that a user is not allowed to post their link to a contest, if ...
5
votes
0answers
56 views

Matrix rotation algorithm

Problem Statement You are given a 2D matrix, a, of dimension \$MxN\$ and a positive integer \$R\$. You have to rotate the matrix R times and print the resultant matrix. Rotation should be in ...
-2
votes
0answers
11 views

How can I make it so the user can input different answers but display the same result? [Python 3.0] [on hold]

I'm wondering how I could display the same result if the user inputs two specific answers in the input command (ie 'end' and 'End'). Here's the code I have so far; everything is working except the ...
2
votes
2answers
49 views

War playing cards based game

How can I make this "War" card game code more visibly pleasing? ...
3
votes
1answer
25 views

Updating multiple membership plan expiration dates at once

I have model action in RequestAdmin like this: ...
1
vote
1answer
47 views

Caesar cipher brute force

I have code that uses the brute force technique to find the message to a Caesar cipher. The program decrypts the message using different keys and then checks whether the resulting words are contained ...
4
votes
1answer
85 views

Yellow Pages scraper

What are your thoughts and comments relating to areas I could improve on? ...
7
votes
1answer
32 views

Simple local source control

I've written my own local "source control". Rather than using a commit-based system, when you're ready to release a version, you can run a command which will create a ...
2
votes
1answer
25 views

Context managers that also deal with sys.stdin and sys.stdout

It's pretty typical for Linux command-line utilities that deal with files to accept either a file as input, or stdin. It's also pretty common for them to be able to ...
1
vote
3answers
22 views

Adding some config to a juniper device

I wrote this script to add some config to a Juniper device. It works well but the whole user input validation section (yes or no section) seems a little messy. Is there a better way I could have ...
6
votes
2answers
276 views

Locating a PID based on an IP address and port

I wrote a simple Python app that is given an IP address and port and the app then finds the PID listening on that IP:PORT. I would like to hear constructive criticism regarding the bellow code. ...
4
votes
1answer
65 views

Using random to generate strings

I have code that reads from files of surnames, female and male names and randomly generates a name in the following format: lastname, male/female name. The files are in the following format: ...
-5
votes
0answers
13 views

Need help writing a removeHead method for a Linked List class [on hold]

Here is what I have so far. If you don't mind looking at my queueType class while you're at it I would really appreciate it. Here are the requirements for the class: Class: ...
-1
votes
0answers
22 views

Python if key in kwargs and key is true [migrated]

if 'force' in kwargs and kwargs['force'] is True: It feels like there should be a better way of writing this condition since I'm repeating both the key and ...
5
votes
1answer
54 views

Compute spherical distance matrix from list of geographical coordinates

I've got a list of geographic coordinates ([lat, long]) and want to compute the corresponding matrix of distances. Distance shall be spherical distance in km. ...
6
votes
1answer
44 views

Input processing/state machine function

I'm making a Mario clone in pygame and I have just wrote a function proccesses inputs and acts as a state machine for Mario. Everything is working just as I want it, but I was wondering if you can ...
5
votes
2answers
78 views

Wordsearch Generator

For fun I decided to make an algorithm in Python that would create a 2D list of a specified size that it can populate with a list of words and fill the gaps with random characters. It's basically a ...
-3
votes
0answers
23 views

Better method for python for loop with only the index [on hold]

Let's say we have an string string= "The quick brown fox jumps over the lazy dog" and I want to iterate over it with only the index. Which is the better method? ...
3
votes
1answer
73 views

Maximum contiguous subarray with recursion

I've implemented the algorithm below for the maximum contiguous subarray problem and would like a review on three specific things: Making the code shorter Making the code faster Any other algorithms ...
4
votes
1answer
66 views

Python exception-raising generator function

I want my generator function to raise as soon as it can. If I make it yield the elements directly, then the KeyError won't happen until iteration begins. Is the ...
3
votes
2answers
244 views

Finding the kth to last element of a singly linked list

I'm not sure if this code is industry-standard or not. Please review it and let me know if any improvement is required. ...
1
vote
1answer
20 views

Transforming markdown files in folders into a documentation

I start coding a simple application: I transform markdown files in folders into documentation. My architecture is very flat. My code looks like a series of unit function called one after the other. ...
5
votes
1answer
45 views

High performance parsing for large, well-formatted text files

I am looking to optimize the performance of a big data parsing problem I have using Python. The example data I show are segments of whole genome DNA sequence alignments for six primate species. Each ...
1
vote
0answers
25 views

Particle Swarm Optimization – second follow-up

This is a followup post to Particle Swarm Optimization. I have a few things I still need to know: Is there a better way of passing variables to the subclass (Particle) other than via the subclass ...
-4
votes
1answer
53 views

Return a sum unless one of the values is illegal

Is there a way to make my code more concise? Given 3 int values, a b c, return their ...
-3
votes
1answer
50 views

Compare counts of string occurrences

Knowing my solution ... Return True if the given string contains an appearance of "xyz" where the ...
6
votes
3answers
96 views

Basic/beginner interactive program in Python

I bring this code review plea over from suggestions from SO. I've made the suggested edits from that thread, except I kept one sys.exit() call because I was having ...
4
votes
2answers
75 views

Character instance slowdown

I'm making a Mario clone in PyGame and I am writing a function that, after releasing the left and right button while Mario is moving horizontally, slows him down until he is at rest. As of right now, ...
2
votes
2answers
56 views

Mergesort through recursion

Could someone kindly have a look at the recursive merge sort below and let me know if there are any improvements? I'm mainly interested in either improving the code speed or making the code shorter. ...
1
vote
1answer
31 views

Using logic to compare absolute values

Is there a way to make my code simpler/more Pythonic? Given three int values (a, b, c), return True if one of ...
2
votes
2answers
62 views

Matrix Multiplication Python — Memory Hungry

Here is a snippet from my python script where I am performing: a dictionary lookup a cartesian multiplication of a list of len=500 against a list of len=60, calculating a cumulative addition for ...
2
votes
1answer
24 views

Linux/Windows Text Editor in Tkinter

Over the past couple of days I have been working on a super-basic text editor with Tkinter. It can: Open new files Open files (general) Save files Obviously you can edit any file you open or ...
5
votes
1answer
31 views

Impyla parse user args into SQL query

My Python is super-rusty and I feel like there must be a better way to do the following. I would really appreciate any feedback/pointers so that I can improve my code and skills (or lack thereof!). ...
-1
votes
0answers
13 views

Flask Restless Filtering Query [closed]

I am trying to use filter for query, using requests on Flask Restless. I tried to write the code like this, ...
1
vote
1answer
62 views

Math quiz for teachers & students - follow-up

I have been programming a maths quiz that can be used for teachers an I have have been trying to make the code as short as possible so it is easier to understand. If you have seen my previous post you ...
3
votes
2answers
81 views

Math quiz for teachers & students

I have been programming a maths quiz that can be used for teachers and I have have been trying to make the code as short as possible so it is easier to understand. If there is any way I could make it ...
3
votes
2answers
326 views

Return sum of three values, excluding values within a specified range

Is there a way to make my code simpler? Given three int values, (a, b, ...
-2
votes
0answers
21 views

Determine whether numbers are pythagorean triple? [closed]

I am trying to make Python code that determines whether or not a set of three numbers are Pythagorean triples. It returns false regardless. Please help. ...
-1
votes
0answers
17 views

How to create a random number in an oval [closed]

I need to help to find a way to generate a random number in the circle under the variable random_number. I'm new to this, so can you please make this understandable to a rookie? ...
2
votes
1answer
42 views

Insertion sort via recursion

I'm learning about algorithms and have been recently experimenting with insertion sort via recursion in Python. My code works fine, but I was wondering if there are any possible improvements that ...
6
votes
3answers
138 views

Manipulating a .csv file to look for two common values to create a key, then summing up values

My code reads a .csv file, looks for a couple values to create its key, and then wraps up the data based on a few business rules I have. I'm trying to learn "the right way", so I'd really appreciate ...
4
votes
1answer
23 views

Solving a variation of the “Partition Problem”

In my version of the Partition Problem, I have a set of weights that are all powers of three (1, 3, 9, 27 etc.). I only have one of each weight. There is some object (the weight of this object is ...
5
votes
2answers
89 views

Downloading list of images

This code downloads a list of images, each in a different thread. I have some questions about this code: I don't know how to get information about correcting downloading (sometimes thread just ...
6
votes
2answers
92 views

Python program to check if a set of points is at land or at sea

I have written a program that divides an geographical area up in cells with size 0.002 degrees longitude by 0.001 degrees ...
2
votes
1answer
68 views
3
votes
1answer
13 views

Reading and processing a file using Pandas

I am trying to read a file using pandas and then process it. For opening the file I use the following function: ...