flornquake
  • Member for 8 years, 8 months
  • Last seen more than 1 year ago
  • Vienna, Austria
Guessing Game (Heads or Tails)
Accepted answer
5 votes

Your script isn't bad. But there is always room for improvement: It's bad to mix tabs and spaces. The fact that your code broke when you pasted it here shows why. Good editors have a setting that ...

View answer
Counting letters in a text file
4 votes

Your coding style is good, especially if you're only starting to program in Python. But to improve your code, you should learn your way around the standard library. In this case, the string and ...

View answer
Python calculator script
3 votes

I like how you put divide, multiply, add and subtract each into their own function, but it would be even better if the function returned the result instead of printing it. That way, you can do ...

View answer
Print sum of numbers 1 to 200 except mults of 4 or 7 in Python
2 votes

I think x % 4 != 0 is clearer than x % 4, because: The standard way to check if a number is divisible is x % 4 == 0. Of course that could also be written as not x % 4, but usually, it's not. x % 4 !...

View answer
Inheritance and forcing methods to be called inside another method
2 votes

You could achieve that like this: class Parser: def __init__(self): self.parse = self._validated_parsing(self.parse) def parse(self, text): raise NotImplementedError def ...

View answer
General feedback on Conway's Game of Life implementation
2 votes

Separate different concerns in your code. The function simulate does two things that should be separated, namely changing the state of the world and calling the function that saves it as an image. ...

View answer
User-input prime number generator
Accepted answer
2 votes

It is easy to get a general understanding of what your code does. You did a good job separating the code into functions. It could be made more readable in a few ways though, mostly by doing things ...

View answer
New list from the elements of two lists popping sequentially
1 votes

I would avoid doing x.pop(0) because it is slow (unlike x.pop(), by the way). Instead, I would write (in Python 2): import itertools def alternate(a, b): """Yield alternatingly from two lists, ...

View answer
Iterating over two iterables
1 votes

There is no (general) way of telling the difference between an infinite and a finite iterator. types might be a generator that stops yielding after a million items have been yielded. The only fool-...

View answer
Counting which numbers fall in a certain bracket
1 votes

Looks good, but there are a few things I've noticed that could be better: You should use the with statement when working with files. This ensures that the file will be closed properly in any case. I ...

View answer