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

learn more… | top users | synonyms

0
votes
0answers
16 views

Checking if a value falls between values that contain letters and numbers [on hold]

I am wondering how I should have programmed this, specifically the part of the question that says "Note that the range for R1-1 - R10H encompasses R1-1 to R9-9 and R1A to R10H." - I am not sure of how ...
2
votes
1answer
32 views

Read CSV with 3 columns and group some elements

I have a csv with 3 columns (date, name, number) and it is about 20K rows long. I want to create a dictionary keyed by date whose value is a dictionary of ...
1
vote
1answer
22 views

Autocomplete Trie Optimization

I'm currently playing with the Typeahead problem on Talentbuddy. There are already 2 questions on this subject (Typeahead Talent Buddy and Typeahead autocomplete functionality challenge), but none of ...
3
votes
2answers
62 views

If Elif replacement for expandability

I am having the following problem. My code works, but it seems like it can improve a lot. I am fairly new to python and can't seem to get this block any better. The logic behind it goes like this. I ...
1
vote
2answers
38 views

Putting all desktop items into a new folder

I'm quite a newbie with Python, but I wanted to try my own little project, so I made a small script that puts all the desktop icons/folders into a newly created folder (called "Desktop1") if there are ...
5
votes
1answer
58 views

Lightweight Tic-Tac-Toe in Python

This is a completely functional python script of the Tic-Tac-Toe game. I've used python's set container for almost all data structure and operation. The code is ...
1
vote
1answer
70 views

Performance in Hackerrank challenge “Sherlock and Queries”

I translated the solution by the author to his challenge from C++ to Python. It seems to be correct, but I get timeouts for the test cases 6, 9 and 12. Here is the full challenge description: ...
3
votes
1answer
59 views

Creation of a temp file on Windows

I implemented a test that reads data from temp file on Windows. I originally had an issue that I solved with the help of this answer ...
2
votes
1answer
45 views

Shift\Transform characters in a grid

I wrote this program for a code test on some website. This program do some predefined transformations (transformation can be horizontally, vertically or by shifting to given number of keys) for every ...
2
votes
1answer
54 views

Using datetime in order to name files

I have a script that makes use of datetime in order to name files. Only business days (Mon - Fri) are used. Here is my part of the code that finds the last ...
0
votes
1answer
30 views

Simple QGraphicsScene program

At the documentation for QGraphicsScene, there is a simple example that does not work. I've written a fix that works, and am curious if it could be improved. From the docs (does not work): ...
2
votes
2answers
53 views

Popping and appending on a list

I am learning Python and would like to know if there's a better way to rewrite it. What I am trying to do is to match list A that is passed to a method against a predefined list B. If an item in list ...
1
vote
1answer
14 views

Create virtual host + MySQL tool

This tool adds a new OS user, create directories and configuration files for Apache + NGINX, MySQL (MariaDB) database and user. I tried to take into account the comments from my previous post. Hope - ...
3
votes
1answer
35 views

String to (Multidimensional) List Conversion

Some background: I'm writing a number of classes that ensure user input is properly validated, and is rejected if it does not conform to expected types (there's also some extra options such as ...
3
votes
1answer
36 views

Comparing data to model and returning a chi squared value

This is quite basic but useful to test various (9) different models using one set of data. I have tried to make it clear and use the PEP8 formatting. I am currently creating a version that can read ...
3
votes
1answer
40 views

Python small brute-forcer

I have 20+ key set. Keyset is like: Key[0] = { "PossibleKey0", "PossibleKey0Another", "AnotherPossibleKey0" } Key[1] = { .... There is an encryption which needs ...
7
votes
2answers
86 views

Espresso Queue simulation

I was asked to do a technical test with the following specification, but my solution was rejected and I was not selected for the available position (Junior to "normal" level, with 4 days of time to ...
2
votes
2answers
42 views

Histogram of length of words in text

This my first real program in python. I welcome harsh criticism. I tried to make it as efficient as possible. Trying to balance speed and readability as well. My program takes a file of text and ...
3
votes
1answer
57 views

Correct practice for Python properties that depend on other attributes

When a property is essentially a boolean value for whether or not an attribute exists or is set a certain way, is it more appropriate to create an object that does not list the option attribute in its ...
1
vote
0answers
22 views

Using URLs and RegEx for web scraper from a dictionary [closed]

I have dozens of functions which GET/POST to some URLs and extract data using RegEx. The URLs and regular expressions were hard-coded earlier but now I moved all of them to a dictionary. I then saw ...
0
votes
0answers
26 views

Python Multiprocessing Early Termination [closed]

While my script is running, it is possible that an error may occur at some point. In that case, all processes should be properly terminated, an error message should be returned, and the script should ...
3
votes
2answers
197 views

Join argv list with spaces

I'm a Python noob. This is the code I'm using: ...
1
vote
0answers
28 views

Comparing different string-matching functions

Here is a problem came from codingbat: Given 2 strings, a and b, return the number of the positions where they contain the same length 2 substring. So "xxcaazz" and "xxbaaz" yields 3, since ...
1
vote
2answers
82 views

Chat server in Python

I just need to know if it's decent or not. Project home ...
1
vote
0answers
43 views

A function for parsing words from a string without using whitespace

I'm trying to parse words from a badly garbled text file that contains many repeats. It's about 100k characters in length and was formed from joining many substrings in alphabetical order. I'm ...
3
votes
2answers
97 views

Editing /etc/network/interfaces

I am trying to change static to dhcp in the /etc/network/interfaces file and vice versa ...
1
vote
1answer
26 views

Robustly dealing with malformed Unicode files

I'm writing a script that deals reads UTF-8-encoded XML files and writes parts of those files into a tempfile for further processing. Sometimes, the input files will have a few malformed characters. ...
-1
votes
0answers
13 views

Matplotlib: 2D color plot with irregular spaced data (mlab.griddata) [closed]

I want to create a colorplot of some irregularly sampled data. I've had some success with the interpolating using matplotlib.mlab.griddata. When I plot the interpolated data (using ...
2
votes
1answer
17 views

Reduce and condense a non standard SessionWizardView

As I'm slowly getting the hang of Python and Django I'm becoming increasingly worried about the volume/quality of code I have. This is my first time building a Python/Django Application and I'm ...
2
votes
2answers
64 views

Answer to an implementation of Project Euler #8

I saw that there was a previous question asking to review an answer to the Project Euler question #8. My answer didn't look anything like the answer in that question and as a beginner, I was wondering ...
3
votes
1answer
40 views

Madlibs Program

I just started to learn Python, and wrote this Madlib program that works the way I intended it to, so I do not need help debugging, just some advice on tips to improve the code or make it simpler. ...
4
votes
1answer
57 views

Functional Knapsack Problem in Python

This is the knapsack problem from rosettacode.org: A tourist wants to make a good trip at the weekend with his friends. They will go to the mountains to see the wonders of nature, so he needs to ...
3
votes
1answer
17 views

Implementation of *nix ipcalc

I posted a JS subnetting calc before, but I wanted to try a CLI version, so I made this. The parts I'm most worried about are: structure (could I refactor the layout better?) Did I goof any math? ...
1
vote
2answers
38 views

Number of maximal PAIRS-values

I had an interview question like this: In a company there are different people. One can measure how well they suits for pair coding as follows: First, let us compute the PAIRS-value which ...
0
votes
0answers
15 views

signal handling using threading python [closed]

I am trying to check a counter status in a certain time duration using signal handler in python. I am trying to see if the counter value increases by 1 within 3 seconds and also if it increases by 3 ...
2
votes
2answers
68 views

Rock-Paper-Scissors in procedural and object-oriented

I am comfortable with the procedural style, and learning the object oriented, so I have done a small Rock Paper Scissors game in both styles. This script is in procedural style and this one is in ...
4
votes
0answers
37 views

Better method of a timer in Python

I am currently using: ...
1
vote
0answers
22 views

Extracting country data from HTML tables

I am trying to optimize/improve my coding skills in python The rationale behind this code is to extract some data from files and store them in a dictionary. I tried to comments lines to improve ...
1
vote
1answer
29 views

List of lists of arrays, zipping, modifying in place

I came back to some old code today and freaked out. I was like "How does this even work, and if it works it can't do what I intended." I ran a few quick tests and confirmed it did actually do what ...
1
vote
1answer
29 views

Colorbar for Matplotlib 3D patch plot

I am trying to make a 3D grid plot in Python using Matplotlib. The grid consists of hexahedral cells (with qudrilateral surfaces). The surfaces should be colored according to their height, that is: ...
3
votes
1answer
46 views

Averaging a list of intersecting rectangles

I have a list of rectangles as tuples (x, y, w, h). I need to find which ones intersect and if they do, average all the intersecting rectangles into a new rectangle. I also track the resultant ...
1
vote
0answers
30 views

Lightweight tabulation written in Python

I wrote this module in python for some minor tabulation needs in my science projects. This was very helpful for testing, debugging and plotting various data. I often use dictionaries for storing such ...
10
votes
3answers
464 views

Determining whether a number is positive, negative or zero

I am a beginner in Python and am currently learning about making beautiful code. I've started with a small program. Can you please review my code? ...
2
votes
1answer
44 views

Simple web application for benchmark

There is an article where the author tries to compare performance of different web stacks. The result looks pretty controversial. I try to prove that in real use case the difference between scores of ...
3
votes
1answer
113 views

Optimizing code for sequence A064604

I am implementing A064604 - OEIS for positive integers up to 10 billion. I am finding the divisors in \$O(\sqrt N)\$. So, the overall time complexity of running the formula right now is \$O(N\sqrt ...
0
votes
0answers
14 views

Optimizing code for sequence A064604 [duplicate]

I am implementing A064604 - OEIS for positive integers upto 10 billion. I am finding the divisors in O(sqrt(N)). So, the overall time complexity of running the formula right now is O(N*sqrt(N)). How ...
1
vote
0answers
28 views

LogParser function: kill application and send email

I've created a new tool, which parses a specified log file, and if an Oracle exception is there, it kills Tomcat and sends an email notification. I tried to take into account comments from my ...
1
vote
0answers
22 views

Tree Utility in Python

I wrote this piece of code to mimic the *nix tree utility, however, I am not happy with the pad_info=[] part. It's used to make padding according to whether the ...
2
votes
1answer
37 views

Web scraper running extremely slow

I am making my first web scraper in Python. It works great but it runs extremely slow. The website loads in about 10ms but it only does like 1 every couple of seconds. There are about 4-6 million ...
4
votes
2answers
68 views

Python List Continuation with multiple lambdas applied

I'm attempting to apply multiple filters and maps to a list and attempted to refactor into something i believe is more readable. In my code, I am reading a file to create a list of terms, then munging ...