Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
10 votes
4 answers
2k views

Accepting user input for tickets and tips

I've done tutorials as well as searches. I need assistance in simplifying this code. Please don't do it for me- instead inform me of what, where and why you are trying to simplify or write less code. ...
Toby's user avatar
  • 103
1 vote
2 answers
489 views

Read n lines, and count the lines that do not contain the string "CD"

I would like to know how to improve the execution speed of the code below. The context : n is an integer read from the stdin, and represents the number of cases. Each case is represented by a ...
Meher Béjaoui's user avatar
6 votes
2 answers
599 views

A python default dictionary which seamlessly saves to disk

I sometimes do experiments at work and separate the computation and the analysis so I can do the computation on a cluster and the analysis locally and sometimes in a Jupyter notebook. I wrote a class ...
HBeel's user avatar
  • 193
4 votes
0 answers
2k views

subprocess with logging module: tee with StringIO

I've got a long-running process. Once it finishes I need the output. But the user should be informed while it's running. With the logging module I get timestamps ...
A T's user avatar
  • 535
2 votes
1 answer
1k views

Reading a file in Python

I currently have this code to read lines from a file ...
Rey Libutan's user avatar
3 votes
3 answers
12k views

Read file into list when class is instantiated in Python 2.7

I would like to read a file into a list when I create the class below. Once the list is ready, I would like to access it outside the class in order to process more code based on the list which now ...
jes516's user avatar
  • 255
4 votes
2 answers
396 views

Testing third parth software performance [closed]

This is a simple example of script to run the test write/read performance of third party software of the drive in Windows environment. Please let me know if you find any place can be better improved, ...
kiddd's user avatar
  • 49
4 votes
2 answers
9k views

Reading and Writing in same script

I just finished working through Exercise 16 of Learn Python The Hard Way. To further study, I wanted to create a script that will read and display a file's contents on screen, and then have the user ...
R2DPoop's user avatar
  • 41
6 votes
1 answer
20k views

XOR of a list of a numbers

In preparing a solution for the CodeChef "Will India Win" challenge, I am trying to find out the xor of list of numbers. The first line of input contains the number of test cases, 1 ≤ T ≤ 106. ...
Anupam's user avatar
  • 185
4 votes
1 answer
459 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 ...
0x5f3759df's user avatar
6 votes
2 answers
6k views

Processing large file in Python

I have some code that calculates the "sentiment" of a Tweet. The task starts with an AFINN file, that is a tab-separated list of around 2500 key-value pairs. I read this into a ...
Boris the Spider's user avatar
10 votes
3 answers
219 views

Saving player name throughout script-launches

I would like to use this in a program to save users' names even after they relaunch the script. I was just wondering if there were some ways I could clean up this code. Note: this currently was made ...
tda's user avatar
  • 607
3 votes
1 answer
4k views

Reading a large XML file and parsing necessary elements into MySQLdb

I have fair concept in a programming (learner) but not an expert to refactor code at the highest level. I am trying to read a huge (100MB-2GB) XML file and parse necessary element (attributes) from a ...
thchand's user avatar
  • 31