Skip to Content
Mastering Python Design Patterns - Second Edition
book

Mastering Python Design Patterns - Second Edition

by Kamon Ayeva, Sakis Kasampalis
August 2018
Intermediate to advanced
248 pages
5h 51m
English
Packt Publishing
Content preview from Mastering Python Design Patterns - Second Edition

A second example

In our second example, let's reuse the idea of a toy service that helps produce a list of people. But, now we want the first name, last name, and address of people. We will then have a second service that depends on the first one to call it in order to get a list of people and then save that list on disk. Because our Service B depends on the Service A, we will use the RpcProxy class provided by Nameko, as you will see in a minute. The data will be saved using csv.

So, as you may guess, we start our service_second.py code file with the following imports:

from nameko.rpc import rpc, RpcProxyfrom faker import Fakerimport csv

Then, we define the new version of the PeopleListService using the following code:

fake = Faker()class ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Python Design Patterns - Second Edition - Second Edition

Learning Python Design Patterns - Second Edition - Second Edition

Chetan Giridhar, Gennadiy Zlobin

Publisher Resources

ISBN: 9781788837484Supplemental Content