New answers tagged

0 votes

Simple data analysis for forecasting

Header comments Add comments at the top of your file to briefly describe the purpose of your code. Describe the inputs and output and how to run the code. Your question states: extracts data from <...
toolic's user avatar
  • 1,309
1 vote

PySpark: Create a column containing the minimum divided by maximum of each row

For the most part, the code layout is good, and you chose meaningful names for variables and functions. When I run pylint, it complains about these unused imports: ...
toolic's user avatar
  • 1,309
2 votes

Look and Say sequence function

(Rethinking the task, inspired by Matthieu M.'s answer.) The sequence grows fast. Exponentially, with growth factor ~1.3 (see the Wikipedia article). For ...
Kelly Bundy's user avatar
  • 3,134
1 vote

Look and Say sequence function

I'd just return your string instead, not convert it to int at the end. Because, really, what are you going to do with it? Most likely you're just going to print it, not use it as a number. In which ...
Kelly Bundy's user avatar
  • 3,134
4 votes

Mathematical calculation of engine fuel injectors

naming Carefully choose identifiers. These are terrific names: GasJetInjector LiquidJetInjector So is Reynolds. But a "similar" prefix is not a good ...
J_H's user avatar
  • 21.9k
7 votes
Accepted

Mathematical calculation of engine fuel injectors

SimilarCalculations is not a very good name. If we interpret it to be a superclass of your other two classes, it can simply be ...
Reinderien's user avatar
  • 60.5k
5 votes

Reassure user that python code is running during long imports

A strange game. The only winning move is not to play. -- War Games, Joshua / WOPR I don't know what your set of imports is. ... the user sits in front of an ...
J_H's user avatar
  • 21.9k
2 votes

SQLite querybuilder class in python

It's good that there is some logging built-in, but this is not the right way to do it. It is inflexible: the output goes to a file (console is useful for debugging) and the format cannot even be ...
Kate's user avatar
  • 6,400
2 votes

SQLite querybuilder class in python

version use Python 3.6 I'm still not believing the constraint, given that interpreter should come from a venv rather than from /usr/bin, but fine, let's roll with ...
J_H's user avatar
  • 21.9k
1 vote

Simple Python text file Parser and Converter

pass class ParserInterface(ABC): @abstractmethod def parse(self) -> None: pass At the end there we had to write ...
J_H's user avatar
  • 21.9k
2 votes
Accepted

Simple Python text file Parser and Converter

Naming Method/function names, parameters, and variable names should be snake_case Parser.parse This doesn't have to be a ...
C.Nivs's user avatar
  • 2,887
6 votes
Accepted

Look and Say sequence function

There are some problems with your code. feeling guilty Hard coding an initial value is perfectly ok. However I do not agree it is the 'first' value. I consider it the second one. If we initialize <...
stefan's user avatar
  • 2,915
7 votes

Look and Say sequence function

Naming The iterations argument is not a great name. The purpose of the function is to return the n-th element of the sequence, and whether this element is obtained ...
Matthieu M.'s user avatar
  • 4,932
5 votes

Look and Say sequence function

I agree with the documentation and testing comments of another answer. Additionally, there are a few points worth considering. This statement is not obvious to me: ...
toolic's user avatar
  • 1,309
2 votes

Look and Say sequence function

signature annotations def look_and_say(iterations): Here, let me help you out with that: ...
J_H's user avatar
  • 21.9k
1 vote
Accepted

Event manager based on decorators

test_envent.py nit, typo in module name. ... transforms a function into an event quibble: Maybe "... into an event generator" modern type annotations ...
J_H's user avatar
  • 21.9k
2 votes
Accepted

Python exception for handling invalid argument types

missing review context This submission of a utility class is off-topic, as it does not offer any examples of caller code that relies on the utility. We can't see how caller's life is made better by ...
J_H's user avatar
  • 21.9k
2 votes

Random number guessing game (1-100)

If you type in anything other than 'y' or 'n' to the question, the program will terminate, instead of asking again. You should also allow 'Y' and 'N' as inputs. You can achieve this like so: ...
TrayMan's user avatar
  • 183
1 vote

Random number guessing game (1-100)

This review adds points to the other review. I agree that the code is well formatted and easy to read. Much easier to read then my first try at this some 38 years ago, but Python is generally easier ...
Maarten Bodewes's user avatar
2 votes

Random number guessing game (1-100)

Generally, the code is easy to read and understand. You chose meaningful names for variables and functions. It also runs well with expected inputs. You should consider using more than 2 spaces for ...
toolic's user avatar
  • 1,309
1 vote

Python code to calculate STM CRC32

word at a time There's no need to painstakingly assemble the value v from its four constituent bytes. We have arrays to do that for us. ...
J_H's user avatar
  • 21.9k
1 vote

Python code to calculate STM CRC32

Accumulating impressions/insights. Not a full review: Shifting right instead of left saves a mask operation here&there and avoids numbers getting longer Assembling ...
2 votes

Speed up search function for PDFs

So I have taken onboard most of what was suggested and have moved towards pushing a list into the function. I have cleaned up the function, and am now using ...
Cam's user avatar
  • 235
5 votes

Python SQL insert to MSAccess with VBScript

I'm stuck in the same situation (managing a database with MS Access frontend), so I can't comment on the technologies used here. However, for the VB Script itself, I highly recommend parameterizing ...
ApexPolenta's user avatar
10 votes
Accepted

Speed up search function for PDFs

where did the time go? Thank you for including measurements. Ordering the profiler output by call count is uninteresting. What you care about is time spent, and the output makes it pretty clear that ...
J_H's user avatar
  • 21.9k
2 votes

Read millions of integers from stdin and process them in Python within 2 seconds

use isort You may as well, there's no reason not to. This is phrased a bit oddly, on two lines rather than one. from sys import stdout from sys import stdin Run ...
J_H's user avatar
  • 21.9k

Top 50 recent answers are included