Tagged Questions

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

learn more… | top users | synonyms

-1
votes
0answers
6 views

Writing wrapper function and handling exceptions correctly in Python

I am writing test scripts using Selenium Webdriver and I have created a simple framework for tests step-by-step execution. My goal was to improve the readability of the code as well as the logic of ...
-2
votes
0answers
12 views

python turtle graphics projectile is not working [on hold]

Trying to make my projectile increase/decrease velocity and increase/decrease angle based on the arrow keys. What am I doing wrong because I am not getting any errors but nothing moves except my space ...
0
votes
1answer
9 views

Django ListView with MySQL query for the queryset

(Note: Even if you don't know Django, it's probably the query that needs work anyway, so you probably don't need to know Django/Python) I have a ListView that ...
0
votes
0answers
14 views

Python - call all methods of a class [on hold]

I'm wondering if my design is flawed or if I'm thinking this incorrectly: I have a class Lexer that has a number of methods. All methods are ...
2
votes
1answer
47 views

Node2D and Node3D classes implemented using a shared decorator

I have the following classes. validator is a decorator that receives a class which defines validation criteria for a decorated function. ...
3
votes
1answer
22 views

Compute adjacent days from date string

I'm trying to do some datetime processing. The input is a string of the form 20141005 ('%Y%m%d') and I want to return a data ...
7
votes
5answers
315 views

Python odd number diamond

I worked up a quick diamond program that takes only odd numbers while returning an error with even numbers or 0. The code looks rather ugly to me, especially with the recurring ...
1
vote
0answers
12 views

Transfer Python data structures through ssh

I need to communicate between 2 machines through ssh to do some processing on one of the machines, and at the end, transfer the output to the first machine. Given ...
3
votes
3answers
79 views
5
votes
2answers
237 views

Convert Roman to Int

I made a function that converts Roman letters to integers. But I'm not happy with it, as I feel like I used too much code for a such a simple task. Any suggestion on how I can minimize it? ...
0
votes
3answers
50 views

Optimize the process program

The program below is about finding the values below the percentage and splitting them into five different output files. This works great for small input data files. But when I am trying to run it for ...
-3
votes
0answers
27 views

Run time error in spoj's prime1 solution in python [on hold]

I am able to get the correct outputs on my Ubuntu system but getting run time error when i submit the solution.I am using python3.4 for the same.Here is my source code. ...
0
votes
0answers
22 views
+50

jQuery slider in a Python/Django SessionWizardView

I have created a Data Verification page in a Django SessionWizardView where a user has to confirm an earlier submitted rating of an image using a jQuery UI Slider ...
-2
votes
0answers
27 views

Classes examples - examination for improvement and fix [on hold]

I did the class coding according to these: Product attributes: name: str ...
0
votes
0answers
24 views

Creating Data Structure Class [on hold]

I am writing a data structure class (Balanced Trees) in Python. I'd like to ask some questions in order to write better code. 1- Do I need to keep fields protected, or no. Is there any difference? ...
1
vote
1answer
57 views

Utilization of Steam APIs and web-scraping

Some background info here: This is a small fun project I made utilizing Steam APIs and web-scraping This is the first time I've ever used Python, so I'm not very familiar with the language I used ...
2
votes
2answers
51 views

Replacing a column with another column

I wrote this below script which basically replaces the one of the column in the df with another column with incremental IDs. The script works perfectly fine but I was wondering if there is a ...
1
vote
0answers
53 views

Real-time bitcoin data feed and storage using websocket framework

I'm trying to create data feed script for real time bitcoin data for OkCoin exchange using their websocket API (documentation) and a database manager for storing. There are two channels i am ...
0
votes
0answers
21 views

Using Python to deal with pop-up windows in Mozilla [migrated]

I'm creating a script for my brother that automates signing in to his university account, downloads his calendar file, and then uploads it to Google calendar since that's what he uses. I've gotten all ...
0
votes
0answers
11 views

Speeding up forwarding of Ethernet frames in Python ARP spoof

I've followed a few tutorials on ARP Spoofing with Python/scapy. They all suggest activating the OS IP Forwarding in Linux: ...
2
votes
0answers
26 views

Structure of database model for a Flask project

I'm working on a project with Flask and I'm trying to follow Miguel Grinberg's Flask tutorial as closely as possible while creating what I need for my own project. Overall, how does it look? Miguel's ...
1
vote
3answers
124 views

Calculate CPU% by process from /proc/stat and /proc/<pid>/stat

We don't have the possibility to install modules like psutil on some boxes, thus I decided to write a simple script to calculate the CPU percentage by the given ...
0
votes
2answers
56 views

Pick a column for each row by column-header name

I am parsing a table: |-------| |Bar|Foo| |-------| | 5 | 6 | |'f'|'g'| | 1 | 8 | |_______| I've tried a number of ways of ...
3
votes
0answers
23 views

BK Tree implementation

I'm working on a system that can search for similar images. This involves being able to search by edit-distance, and as such I've implemented a special data-structure called a BK tree. Some notes ...
2
votes
0answers
26 views

Fast draw wxPython OnPaint

I have the following wx.Window: ...
2
votes
0answers
26 views

Python code to write simple VPK archive files

I'm new to Python, but have a lot of experience with C and C++. I would appreciate some feedback on my implementation of a packer for this archive format. Specifically, any feedback on how idiomatic ...
5
votes
1answer
63 views

Monte Carlo AI in 21 game

I am very interested in the Monte Carlo AI. I tried my best, still, this AI plays very badly. This code "works" in the meaning that it does not crash, but the quality of play is extremely low. Have ...
10
votes
3answers
538 views

Beginnings of a base-conversion game in Python

I'm pretty very new to python, so I thought that I'd write a game to teach me python and better teach me how to think in hexadecimal and binary. I'm starting off by writing a few functions to convert ...
3
votes
3answers
56 views

Padding a hexadecimal string with zeros

I'm given a hexadecimal number in string form with a leading "0x" that may contain 1-8 digits, but I need to pad the number with zeros so that it always has 8 ...
3
votes
1answer
60 views

Convert between two bases, each between 2 and 36

I'm doing some Python practice for fun and I wrote some code that converts between two bases. I'm thinking about expanding on this later, so the docstrings are pretty redundant from function to ...
0
votes
0answers
4 views

Plugins and exporting an API between python scripts [migrated]

I've got a python script, which should read a subdirectory and make all the scripts within it callable like this: python mainscript.py subscript arguments I've ...
4
votes
1answer
120 views

Sum of numbers which are not sum of two abundant numbers

The following program is a solution to Project Euler Problem 23. That problem defines an abundant number to be one whose sum of proper divisors is greater than it, tells us that all integers at least ...
3
votes
1answer
64 views

Merge sort in Python

I've written a implementation of a merge sort in Python. It seems correct and I have tested it with this: ...
0
votes
0answers
5 views

How to make a smiley face in Turtle? [migrated]

First time ever using Turtle. My assignment is to make a smiley face, any size and any position. I just can't get the mouth right because I really don't know what I'm doing. I've read quite a bit and ...
2
votes
1answer
45 views

Defining functions in Vigenere cipher

I'm trying to learn the process of defining/calling a (somewhat) complex function. I understand the main idea, and can do it on a small (simple) scale. A simple example: ...
3
votes
2answers
158 views

Generating character permutations

I want to generate a 'dictionary' containing all 8 character permutations of upper-case letters such that the output file looks like: ...
3
votes
2answers
58 views

Eurovision voting order

Part of the Eurovision Song Contest is the voting process to determine the winner of the contest. Each country gives between 1 and 12 points to its 10 most favorite songs. When all the points have ...
2
votes
2answers
65 views

Summing all parameters, except the last, which should be subtracted instead

Working on some python koans and got one which states: ...
2
votes
2answers
140 views

Function that takes an array of integers and returns that array rotated by N positions

Example: if \$N=2\$, given the input array \${[1, 2, 3, 4, 5, 6]}\$ the function should return \${[5, 6, 1, 2, 3, 4]}\$ Here is my code: ...
2
votes
2answers
42 views

Small CLI note manager and publisher

This is my first attempt at trying to make a CLI note manager, than can be easily published on the web. I have made one note and you can see it live here. I have added some comments, and placed the ...
2
votes
1answer
58 views

Creating objects from parsed file

I'm newbie in Python but I want to know some tricks to make my code look cute. I know that syntax of Python allows to do this, but I don't know how. Suppose I have file with lines of format "x y z" ...
3
votes
1answer
44 views

Fast counting of interactions between groups given users interactions and groups assignments

Given: An array c that contains the group assignment of every user (c[i]=4 indicates that user i belongs to group 4) A matrix ...
3
votes
1answer
113 views

Find next highest number with the same digits

Question: Given any integer, efficiently find the next highest integer that uses the same digits. For example if the number is 15432, you should return ...
1
vote
1answer
46 views

Writing a Pythonic prime sieve

I'm practicing writing code less by brute force. I'd like feedback for writing a prime sieve more Pythonic, simpler, or more creatively perhaps. ...
1
vote
2answers
71 views

Enhance a Caesar cipher

I have just written a simple program to implement the Caesar cipher using lists. The program assumes the input will be all capital letters. I'm quite new to Python and am just curious of some more ...
3
votes
1answer
42 views

Calculating the distance squared between all vertex-pairs of a number of 2D polygons

I have implemented my code using Cython. It is the current bottleneck in my computations. There are two non-numpy functions involved: calculate_2D_dist_squared ...
2
votes
2answers
39 views

has_cycle in directed and undirected graphs

I wrote a program that can tell if a graph has_cycle or not. Can you please suggest more elegant and eloquent ways for this program? (Perhaps better ways to represent a graph with vertices and ...
1
vote
2answers
65 views

Reverse Message Program

...
3
votes
5answers
202 views

Finding if a given number is in a given range based on a flag

Question Description: Given a number n, return True if n is in the range 1..10, ...
1
vote
1answer
49 views

Automatic password security test for WordPress

I was bored the other day and wrote the following little script to attempt to find insecure passwords for WordPress blog owners so they could be notified of how easy it would be to crack their WP ...