Skip to Content
Hands-On Reactive Programming with Python
book

Hands-On Reactive Programming with Python

by Romain Picard
October 2018
Intermediate to advanced
420 pages
10h 26m
English
Packt Publishing
Content preview from Hands-On Reactive Programming with Python

Maximizing code readability

One of the main benefits of using AsyncIO and ReactiveX is that it allows us to write code that can be read quite easily. However, there are two things that can make RxPY code less readable than the ReactiveX equivalent in other languages (especially compared to JavaScript):

  • The intensive use of dictionaries
  • The way to deal with continuation lines

The following code snippet shows a typical way to chain RxPY operators:

obs = Observable.from_([{'count': 5, 'what': 'apple'},                        {'count': 3, 'what': 'orange'}]) \    .filter(lambda i: i['what'] == 'apple') \        .map(lambda i: i['count']) \    .map(lambda i: {'count': i, 'double': i*2} ) \...

When a lot of operators are chained together, in most cases there is a need to return ...

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

Python Programming with Design Patterns

Python Programming with Design Patterns

James W. Cooper

Publisher Resources

ISBN: 9781789138726Supplemental Content