Skip to main content
Stack Overflow's 2025 Annual Developer Survey is still open — take the Survey before it closes
11 votes

Extract unique email addresses from a text file

Explicit contract Returning an empty list to indicate "file not found" is probably the only big sin here. Now your function returns the same empty list in both of the following cases: File ...
STerliakov's user avatar
  • 1,673
10 votes

Extract unique email addresses from a text file

High level advice: the RFCs have many subtle details — prefer to rely on a well tested library that understands the spec before you roll your own. design of Public API ...
J_H's user avatar
  • 40k
7 votes

Iterative Deepening A* implementation of 15 Puzzle solver in Python

Bug get_valid_ordered_moves returns invalid moves. You can't check row overflow by modified index alone, so your check will allow move from cell number 7 (...
STerliakov's user avatar
  • 1,673
7 votes

Extract unique email addresses from a text file

A couple of points on your function: ...
Chris's user avatar
  • 2,383
6 votes

Extract unique email addresses from a text file

Documentation The PEP 8 style guide recommends adding docstrings for functions. For example: ...
toolic's user avatar
  • 12.6k
5 votes

Extract unique email addresses from a text file

One thing that always annoys me about sites collecting email addresses. user@EXAMPLE.COM are the same ...
David G.'s user avatar
  • 1,596
4 votes

Extract unique email addresses from a text file

We have seen several answers about how to improve your python, and why using a regex to detect a mail address is a bad idea, but there's one more thing I want to point out: Reading a complete file in ...
Guntram Blohm's user avatar
3 votes

Functions to check if object matches type and reverse a string

Let's first look at the is_type function. This is about handling types, and indicative that one should be careful in separating something being of a type – ...
MisterMiyagi's user avatar
2 votes

Kaggle Notebook for Identifying House Plants

module docstring First, in any language, avoid repeated "----" or "====" ASCII art in comments. Prefer to use whatever tools the language offers in order to better organize your ...
J_H's user avatar
  • 40k
2 votes

Value at Risk forecast generator

Comments Remove commented-out code to reduce clutter: # Print other information (optional) # print(daily_return.shape, len(weights)) # print(daily_return.columns) ...
toolic's user avatar
  • 12.6k
2 votes
Accepted

Kaggle Notebook for Identifying House Plants

Overview The code layout and organization is good, the function docstrings are helpful and you used meaningful names for functions and variables. Comments It is good that you added comments at the top ...
toolic's user avatar
  • 12.6k
2 votes

Iterative Deepening A* implementation of 15 Puzzle solver in Python

Here are some minor style suggestions not covered in the previous answer. Simpler The print_board inner for loop is slightly ...
toolic's user avatar
  • 12.6k
2 votes

Combination of three vocabulary sets

Your set of loops and conditionals to build result can be built more declaratively using a list comprehension. ...
Chris's user avatar
  • 2,383
2 votes
Accepted

Splitting input text into fixed-size overlapping word chunks

Your tests are pretty good, and helped me during refactoring. I think they all make sense save the empty case: in my refactor an empty string generates no chunks rather than one empty chunk. I can't ...
Reinderien's user avatar
  • 69.4k
1 vote

the 10001st prime number

While a sieve is a good way to calculate primes, if you need to find some arbitrary Nth prime, your memory requirements may become onerous. This can be improved by implementing a segmented sieve, ...
Chris's user avatar
  • 2,383
1 vote
Accepted

Flask App for Weather Prediction Using Machine Learning

Comments It is great that you incorporated advice from previous reviews. However, there is no need to permanently add comments to the code which merely state that you did so. For example, comments ...
toolic's user avatar
  • 12.6k
1 vote
Accepted

Predictive Maintenance ML Project in Jupyter Notebook

Documentation The PEP 8 style guide recommends adding a docstring at the top of the code to summarize its purpose. You could convert the header comments to a docstring: ...
toolic's user avatar
  • 12.6k
1 vote
Accepted

ML Project: Predictive Maintenance in Jupyter Notebook

Simpler You can simplify the logic of if/else statements like this: if not numeric_df_for_corr.empty: else: by removing the <...
toolic's user avatar
  • 12.6k

Only top scored, non community-wiki answers of a minimum length are eligible

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant