Skip to content

Instantly share code, notes, and snippets.

@inesp
Created September 2, 2019 13:23
Show Gist options
  • Save inesp/dc739cf383963f7a1a608c83e518154f to your computer and use it in GitHub Desktop.
Save inesp/dc739cf383963f7a1a608c83e518154f to your computer and use it in GitHub Desktop.
from datetime import datetime
from models import Person
class Zoo:
def __init__(zoo_config):
self._owner_name = zoo_config["owner"]
# 1. owner appears to be mandatory, it is actually the owner's name
self._free_entrance_day = zoo_confi.get("free_entrance_day", "Monday")
# 2. free_entrance_day is not mandatory, it must be the english name
# for a week day, can I set it to None in zoo_config or will this
# cause a problem later?
...
...
def owner(self):
return Person.query.filter(Person.name == self._owner_name).one_or_none()
# 3. aha, this line will raise an error if I use the wrong letter case or
# trailing spaces for the owner
def is_entrance_free(self):
today = datetime.today().strftime('%A')
return today == self._free_entrance_day
# 4. aha, the entrance_day must be in the strftime format %A
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment