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

Function to divide a string for seperate lines for output [on hold]

I'm a huge fan of command line programs. Most of my programs are command line ones, they're relatively easier to use and implement without any GUI overhead. The problem is, I want my output to be ...
0
votes
0answers
11 views

Speed up Pandas DataFrame expansion to include time-lagged information about events

Using pandas and Python 3, information about a simple timeseries data set is being processed. Within the span of .5 seconds, 3 names are being said. We record the onset of each utterance, the length ...
3
votes
3answers
83 views

Object Interaction in OOP (especially Python) [on hold]

Say you have a number of similar objects (e.g. instances of the class Person). Each of these instances can belong to a number of Groups, also represented by a class. To stick with the examples of ...
-3
votes
0answers
12 views

Repeat…Until Type a python code [on hold]

PrintedTotal 0 AudioBookTotal 0 EBookTotal 0 REPEAT READ next record IF BookType = “printed” THEN PrintedTotal PrintedTotal + 1 ELSE IF BookType = “audio-book” THEN AudioBookTotal ...
2
votes
1answer
21 views

Format a number to include commas

This is my attempt to format a number and put commas where appropriate. I was wondering if this could be done in a simpler way. It's used by calling ...
7
votes
2answers
46 views

Quicksort in Python

This is my first actual attempt at writing a Python program. I have a background in C++, so it was a big change (where's my iterators?), and I'm looking for criticism on my use of Python and its ...
4
votes
1answer
46 views

Tic-Tac-Toe game using the minimax algorithm

I have written a Tic-Tac-Toe game in Python that contains, among others, a player that uses the minimax algorithm. I am not exactly a beginner at Python, but I'm not very experienced with it - so I ...
2
votes
1answer
41 views

Index of letter removed to make string palindrome

This code finds the index in the string and removes the one which will make the string a palindrome. If the string is already a palindrome, it should return -1. This code works correct, but I am ...
2
votes
1answer
26 views

Fuzzy matching dict keys

What do you think of this idea? It's supposed to be a dict that makes a reasonable guess at the key you were trying to access for getters and deleters. Setters should be untouched. Similar to how ...
1
vote
1answer
30 views

Finding the largest repeating substring

Here's my code that takes a large string, and searches for the longest reoccurring substring. It compares the first letter with every other until it finds a match, then saves it. Then it compares the ...
3
votes
2answers
30 views

Calculating parsimonies using Python; performance is lacking

This program takes a very long time to do each and every step, even the very first print statement. Why is this, and what is the best way to diagnosing a problem like this in any language? Also, I'd ...
-1
votes
0answers
14 views

Short way to search text

Making an email program, I know that there has to be a better way to do this. ...
5
votes
1answer
64 views

Horridly Inefficient Project Euler #14 in Python - Collatz Sequences

I created this solution a while ago, and have been going back over my problems to try to make them all more efficient. I have been stuck on this one, and have tried a few different ideas. So far, my ...
3
votes
1answer
46 views

Check string(line) in a file and send email

I want to check some lines from a log file [check msyql replication slave status log] named "status.txt" (size is always about 3-4 KB): Slave_IO_Running: Yes Slave_SQL_Running: Yes If any of ...
8
votes
3answers
279 views

Electricity Calculator

This is a calculator for Ohm's Law and Power Law. It works but I'd like some suggestions on making the code look a little cleaner, or run more efficiently. ...
2
votes
0answers
39 views

Python static blog generator

I want to put on review yet another static blog generator script. I don't have much Python experience and would be very thankful if you would explain how I can improve the code. ...
3
votes
1answer
51 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 ...
2
votes
1answer
53 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 ...
4
votes
3answers
91 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
44 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 ...
0
votes
0answers
24 views

Does this parse OS names correctly?

I am making a function to return a two-item tuple of ('os basename', 'os distro'). So for vista return should be ('Windows', 'Vista'), for Fedora it should be ...
5
votes
1answer
76 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
95 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
66 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
46 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
60 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
33 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
59 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
15 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
38 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
37 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
45 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
91 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
45 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
24 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 ...
3
votes
2answers
198 views

Join argv list with spaces

I'm a Python noob. This is the code I'm using: ...
1
vote
0answers
31 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
87 views

Chat server in Python

I just need to know if it's decent or not. Project home ...
1
vote
0answers
47 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
103 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. ...
2
votes
1answer
19 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 ...
3
votes
2answers
67 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
42 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
63 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
39 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 ...
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
38 views

Better method of a timer in Python

I am currently using: ...