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

Avoiding backslashes

The last small thing that prevents RxPY code from being as readable as synchronous procedural code is the usage of backslashes for continuation lines. When an operator chain is quite small, like in the previous examples, then using backslashes is natural. However, it becomes a visual distraction when longer operator chains are used. The easy way to fix this is to wrap expressions in parentheses. Since line continuation is implicit inside an open parenthesis, there is no need to add backslashes.

Moreover, comments are allowed inside the parentheses. This allows us to finally write the code snippet this way:

from collections import namedtupleBasket = namedtuple('Basket', ['count', 'what'])FruitCount = namedtuple('FruitCount', ...
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