Use this tag if you are specifically using Python 2.7. Such questions should be tagged with [python] as well.
-2
votes
0answers
21 views
Python Calculator Help [on hold]
So I wrote a code for a python calculator with much difficulty since I'm totally new to it-.-Its working totally fine but the one problem I'm being encountered with is that the user can add only upto ...
8
votes
3answers
189 views
Model cars as classes
I am learning about object oriented programming in Python using classes. I have attached an image of what I had in mind when structuring my classes. This is supposed script model cars. I want to know ...
1
vote
1answer
31 views
Function to find midpoint of two floats where one of the floats might be an empty string
There must surely be a nicer way of writing this.
The wrinkle of complexity is that prev_seq or next_seq might be an empty string if the user moves the question to the first or last position, but it ...
3
votes
2answers
83 views
Python coding style from Java background
I am pretty new to Python and just wanted to make sure I am going in the right direction with my coding style.
After reading this, I'm not so sure.
The following is a convenience class that has ...
5
votes
3answers
155 views
if statements or eval?
I'm wondering about the following code:
def ValidateGoto(placeToGo):
conditions = {}
conditions["not placeToGo"] = "Enter a positive integer in the text box"
conditions[
...
5
votes
1answer
120 views
Improvements on Python game?
This is a game I made in Python. While it is not my first, I am not happy with the result. I would like suggestions on ways I can make it better, more user-friendly, and more enjoyable. Also, if ...
2
votes
1answer
32 views
Produce product of lists
I want to combine elements in different lists.
For example, here are 3 lists.
list_a : [ 1,2,3 ]
list_b : [ 4,5,6 ]
list_c : [ 7,8 ]
Selecting elements from list_b and list_c is mutually exclusive. ...
6
votes
2answers
89 views
A small Python text adventure “frame”
I've been working on a small "frame" for a text adventure in Python.
So it's less of a real adventure and more of a small testing location for all the commands.
I pretty much just started learning ...
1
vote
0answers
66 views
Python urllib proxy access function - Coverage of possible proxy scenarios
Several of my Python 2.7 programs need to access server tasks via our server apache instance.
The 'client' programs will run on Windows in various environments. They may be run on systems that do not ...
16
votes
4answers
1k views
Regex to parse semicolon-delimited fields is too slow
I have a file with just 3500 lines like these:
filecontent= "13P397;Fotostuff;t;IBM;IBM lalala 123|IBM lalala 1234;28.000 things;;IBMlalala123|IBMlalala1234"
Then I want to grab every line from the ...
2
votes
2answers
208 views
Optimizing Edit Distance Solution
I was doing a standard problem of DP(Dynamic programming) on spoj Edit Distance using python.
t = raw_input()
for i in range(int(t)):
a,b = raw_input(),raw_input()
r = len(a)
c = ...
3
votes
2answers
98 views
Text file reading and printing data
MyText.txt
This is line 1
This is line 2
Time Taken for writing this# 0 days 0 hrs 1 min 5 sec
Nothing Important
Sample Text
Objective
To read the text file and find if "Sample Test is ...
2
votes
1answer
88 views
Opinions/Improvements on a run periodically/timer function in Python 2.7
I'm looking for some opinions on this bit of code that I wrote and if there are any ways it can be improved.
The scripts aim is to run the function runme() every 60 seconds with a random interval ...
1
vote
3answers
157 views
How to optimize this simple Python program?
Here is a simple piece of code in Python. It is a solution to the SPOJ's JPESEL problem. Basically the problem was to calculate cross product of 2 vectors modulo 10. If there is a positive remainder, ...
3
votes
1answer
124 views
More efficient way to find the mode of an array/iterable? (Python 2.7)
I'm currently using scipy's mode function to find the most occurring item in different iterable objects. I like the mode function because it works on every object type I've thrown at it (strings, ...
3
votes
2answers
2k views
Multiple Choice Quiz with Stat Tracking
I was hoping I could get some of you to look over a program I wrote. I am just beginning to learn about Python (for the last month or so). Therefore, I may not be aware of techniques that would make ...
5
votes
3answers
451 views
Python 2.7: Good practice or bad practice? (particularly the use of global)
I've been learning Python 2.7 for about a week now and written a quick program to ask for a names of batters then print a score sheet. I have then added the names to a list which I will use more in ...
0
votes
0answers
88 views
Python 2.7 - Abstract Programming [duplicate]
Possible Duplicate:
Can I make the class more abstract?
import math
class Point:
def __init__(self,x,y):
self.x = x
self.y = y
def move(self,x,y):
self.x += x
self.y += y
...
3
votes
1answer
182 views
Can I make the class more abstract?
import math
class Point:
def __init__(self,x,y):
self.x = x
self.y = y
def move(self,x,y):
self.x += x
self.y += y
def __str__(self):
return ...
1
vote
3answers
409 views
Long-Winded code (multiple 'if' statements)
Any thoughts on my code? It's a simple hashing code written in Python. The code runs from the command line.
There just appears to be a lot of condition "if / elif" entries in both of the main ...
6
votes
1answer
558 views
Welcoming any comments on this Python program that keeps remote folders in sync with local ones
This started as a hacked-together tool to remove annoyances I was facing with experimenting with code on live remote servers, then getting that code into my development environment after ...
3
votes
1answer
824 views
Refactoring - Pythonic, speed and memory optimization
I have fair concept in a programming (learner) but not an expert to refactor code at the highest level. I am trying to read huge (100MB-2GB) XML file and parse necessary element (attributes )from file ...
2
votes
1answer
251 views
Can you review my i18n/Jinja2/python code?
I'm learning to Jinja2 and what's important in this case isn't speed but i18n translations and functionality. With python 2.7 Jinja2 and not django seems to preferred way to go so I'm rewriting much ...
2
votes
1answer
408 views
Is this a safe/correct way to make a python LogHandler asynchronous?
I'm using some slow-ish emit() methods in Python (2.7) logging (email, http POST, etc.) and having them done synchronously in the calling thread is delaying web requests. I put together this function ...