Hacker News new | ask | show | jobs
by lordmauve 4405 days ago
Code review:

default_reasons doesn't need to be a dict. Use a list.

You don't need random.randrange(). Use random.randint() to select a random integer and random.choice() to select a reason from default_reasons.

3 comments

Also, use the print function rather than keyword to make this all shiny Python3 :-)
If I said this was a deliberate .. uh .. irony on my part implying I'm well suited to work at somewhere like BR or Northern, would you buy it?

Fake edit: TY for the review :)

default_reasons seems like an odd choice of name, when there is no other kind of reasons. I'd suggest something like reason_choices or reason_options.

Edit: also I'd make it a tuple rather than either a dict or a list.

Don't make it a tuple. A tuple indicates heterogenous data (a record), while a list indicates a sequence of data.

If nothing else, use lists because the syntax means it stays as a list even if you someday remove all but one option and forget to leave a comma, eg.

  REASONS = [
    'leaves on the line'
  ]
vs

  REASONS = (
    'leaves on the line'
  )
After DDGing a bit it seems like you have a point. I did not know about that semantic difference between tuples and lists in python. It seems like this difference is entirely about the meaning conveyed to a human reader, rather than any technical difference. My guess would be that tuples are generally more efficient, but I have no actual data to back that up with.