pycabook / rentomatic

A demo implementation of a clean architecture in Python.
MIT License
252 stars 88 forks source link

Use more pythonic string format #5

Open yobuntu opened 3 years ago

yobuntu commented 3 years ago

Description

Tank you a lot for this book, it is a great source of inspiration and make the exact bridge i was missing between clean architecture and working with a web framework and ORM.

That being said, i think you may use the string format in a more pythonic (and expressive) way like this:

setup = {
    "dbname": "rentomaticdb",
    "user": "rentomatic",
    "host": "localhost",
}

conn_str = "postgresql+psycopg2://{user}@{host}/{dbname}".format(**setup)
lgiordani commented 3 years ago

Hi @yobuntu thanks for the suggestion. I will add this in the second edition of the book that I'm finalising this month, hopefully it will be out for Christmas. I'll keep this open until it has been properly addressed, anyway