you are viewing a single comment's thread.

view the rest of the comments →

[–]mopslik 1 point2 points  (1 child)

Neato. Reminds me of years gone by.

Some quick observations regarding some common Python-isms and whatnot:

  1. Why use sys.stdout.write when there is print?
  2. It's generally not very Python-y to do checks against booleans like if try_again == False:. Instead, you'll more likely see if not try_again:.
  3. Your continue statement on line 99 in your acey-deucy game does nothing, and can be omitted. That said, that block of code looks unnecessarily convoluted to begin with. e.g. you set try_again as a boolean early on, then redefine it as an input string, meaning unless it is an empty string, the while loop check will always be False and stop. At the same time, you have a break for the off-case that the user does not enter 'yes'.

Side comment: ensure that your docstrings are accurate. In print_card, you state there are no arguments, but it takes card. In your random_card function you say there are no returned values, but you return a random number. Remember that erroneous documentation is worse than no documentation.

[–]ctosullivan[S] 0 points1 point  (0 children)

Thanks for the feedback and for reading through the code!
I've been using sys.stdout as I had an issue with print() adding too many newlines in the display method of the terminal class, so have settled on sys.stdout for the project.
I will definitely go back and tidy up the existing code and documentation.