Antonio Verardi - Write more decorators (and fewer classes)

Share this & earn $10
EuroPython Conference
Published at : 21 Jan 2021
2020 views
29
4

"Write more decorators (and fewer classes)
[EuroPython 2017 - Talk - 2017-07-11 - Anfiteatro 2]
[Rimini, Italy]

In the wake of famous talk “Stop Writing Classes” by Jack Diederich (https://www.youtube.com/watch?v=o9pEzgHorH0), I’d like to present a pattern that can be used to design clean and pythonic interfaces for programmers based on replacing single-method classes with decorated functions.

This pattern is already used by some famous frameworks and libraries, like Pyramid (https://trypyramid.com/), but I believe it isn’t that well-known to many (even experienced) Python developers and is not as widely used as it deserves.

I’ll show how this pattern can be employed to improve a programming interface which is used by an internal log processing framework at Yelp. This will demonstrate how a more functional approach, leveraging the power of Python decorators, can lead to simpler, more beautiful and easier to understand code.

However, this talk doesn’t suggest giving up classes altogether, but making use of them only when they are truly useful. In fact, the use-case I’m going to analyze will combine classes, functions, and decorators to make the best out of these tools.

Given that the presentation is going to be very code-oriented, the talk is intended for an audience of developers who are already familiar with most Python constructs, including decorators, even though the concept will be briefly introduced at the beginning of the talk. But, if you are one of these people, I promise you that the code will speak for itself.

License: This video is licensed under the CC BY-NC-SA 3.0 license: https://creativecommons.org/licenses/by-nc-sa/3.0/
Please see our speaker release agreement for details: https://ep2017.europython.eu/en/speaker-release-agreement/
AntonioVerardiWrite

Madeleine Peyroux - "Instead"

Madeleine Peyroux - "Instead"

Judikay Capable God Cover by Regina Ansah.

Judikay Capable God Cover by Regina Ansah.

Tetralogy of Fallot: Current Surgical Treatment

Tetralogy of Fallot: Current Surgical Treatment

Grey squirrel shooting tactics

Grey squirrel shooting tactics

Build a House in 24 Hours / Challenge!

Build a House in 24 Hours / Challenge!

DIY: COMO FAZER PAPEL ENVELHECIDO (Pergaminhos e Rótulos Bottle Charms - Old paper Medieval Scroll)

DIY: COMO FAZER PAPEL ENVELHECIDO (Pergaminhos e Rótulos Bottle Charms - Old paper Medieval Scroll)

Everything about becoming a PHYSICIAN ASSOCIATE - sit down with Nealy

Everything about becoming a PHYSICIAN ASSOCIATE - sit down with Nealy

Door of My Heart / Paramahansa Yogananda

Door of My Heart / Paramahansa Yogananda

Exclusive - Preparing for the Conventions: The Daily Show

Exclusive - Preparing for the Conventions: The Daily Show

The Perfect Paradise Beach Scene in 4K: White Sand, Blue Water & Waves - Two Hours

The Perfect Paradise Beach Scene in 4K: White Sand, Blue Water & Waves - Two Hours

Maneva - Luz que me traz paz (Letra)

Maneva - Luz que me traz paz (Letra)

الاستعداد للطيران و الطيران من مطار القاهره الدولي

الاستعداد للطيران و الطيران من مطار القاهره الدولي

Cabinet Secretary Ajit Seth speaks on steps taken by the govt to tackle Swine Flu

Cabinet Secretary Ajit Seth speaks on steps taken by the govt to tackle Swine Flu

STOP Saying This Wrong! | How To Use 'To' and 'For' Correctly in 5 Minutes

STOP Saying This Wrong! | How To Use 'To' and 'For' Correctly in 5 Minutes

CYBERBUG 2077 - Some bugs I came across in Cyberpunk 2077!

CYBERBUG 2077 - Some bugs I came across in Cyberpunk 2077!

Lots X İnzi - Ara Ara (prod. by Gokhan Ekinci)

Lots X İnzi - Ara Ara (prod. by Gokhan Ekinci)

I Don't Have Anything ~ John Thornton (Richard Armitage)

I Don't Have Anything ~ John Thornton (Richard Armitage)

Facial Plastic Surgery Before and After : 15 Years Younger

Facial Plastic Surgery Before and After : 15 Years Younger

What Does a Peer Specialist Do?

What Does a Peer Specialist Do?

Team Ripper Thor & Luzifer v Team Eruption Tango & Ill Tempered Mutt Colchester 2019

Team Ripper Thor & Luzifer v Team Eruption Tango & Ill Tempered Mutt Colchester 2019

Cautious Clay - Agreeable

Cautious Clay - Agreeable

The Complete History Of Top Lane And The Top Lane META

The Complete History Of Top Lane And The Top Lane META

A Taste of the Custom Online Programs at Stanford GSB

A Taste of the Custom Online Programs at Stanford GSB

Building a 3.5kWh DIY Solar Generator for $650 - Start to Finish

Building a 3.5kWh DIY Solar Generator for $650 - Start to Finish

*NEW* 4 PENGUINS vs -10 IQ MORTIS 😂 Brawl Stars Funny Moments & Wins & Fails #256

*NEW* 4 PENGUINS vs -10 IQ MORTIS 😂 Brawl Stars Funny Moments & Wins & Fails #256

"HAIYAA" Will be Someone's Last Words - Rice To Meet You #87

"HAIYAA" Will be Someone's Last Words - Rice To Meet You #87

10 Players That Rejected Liverpool

10 Players That Rejected Liverpool

TRUCK CAMPER TOUR after 2 YEARS on the road // Tour Our Remodeled Tiny House on Wheels // CtW

TRUCK CAMPER TOUR after 2 YEARS on the road // Tour Our Remodeled Tiny House on Wheels // CtW

Bring Forth Ye Shadow

Bring Forth Ye Shadow

Laura Story - You Cannot Be Stopped (Official Lyric Video)

Laura Story - You Cannot Be Stopped (Official Lyric Video)

Smart Phrases to compare & Contrast in English? Adjectives | Degree of Comparison | Grammar Lesson

Smart Phrases to compare & Contrast in English? Adjectives | Degree of Comparison | Grammar Lesson

Patrick Mahomes jokes that maybe playing at Hard Rock Stadium isn't for him

Patrick Mahomes jokes that maybe playing at Hard Rock Stadium isn't for him

Sewing Projects To Make In Under 10 Minutes

Sewing Projects To Make In Under 10 Minutes

LIKE A BOSS 2019 AMAZING MOMENTS

LIKE A BOSS 2019 AMAZING MOMENTS

OSCARS : Every Best Directors of the century so far (2000-2020) - TRIBUTE VIDEO

OSCARS : Every Best Directors of the century so far (2000-2020) - TRIBUTE VIDEO

Lesson 676 - How to use There Is and There Are in English | by Socheat Thin

Lesson 676 - How to use There Is and There Are in English | by Socheat Thin

'No More Caveman!' Homeless Piano Prodigy Stunned by His Remarkable Makeover

'No More Caveman!' Homeless Piano Prodigy Stunned by His Remarkable Makeover

Snowboard Kids N64 - Continue?

Snowboard Kids N64 - Continue?

Bleached - Searching Through The Past // THEY SHOOT MUSIC

Bleached - Searching Through The Past // THEY SHOOT MUSIC

Opting for 6-Month Moratorium? You may end up paying this much extra | #StayHome Learn Money #WithMe

Opting for 6-Month Moratorium? You may end up paying this much extra | #StayHome Learn Money #WithMe

Strasbourg - Entirely Skippable

Strasbourg - Entirely Skippable

Preventing COVID-19 in your workplace or while teleworking

Preventing COVID-19 in your workplace or while teleworking

TOP QUALITY ROOM FOR RENT IN ABU DHABI | New and affordable | Bozman TV

TOP QUALITY ROOM FOR RENT IN ABU DHABI | New and affordable | Bozman TV

The Priority of Persons Revisited

The Priority of Persons Revisited

Bronte Does a Huge Burnout In The Wagon as I Uncontrollably Stress!

Bronte Does a Huge Burnout In The Wagon as I Uncontrollably Stress!

Plan December 2020 with me | Plan your December set monthly goals with me| Interactive plan with me

Plan December 2020 with me | Plan your December set monthly goals with me| Interactive plan with me

7 Terrifying Close Calls Caught on Camera #2

7 Terrifying Close Calls Caught on Camera #2

The Conventional Deadlift | How to Perform The Conventional Deadlift

The Conventional Deadlift | How to Perform The Conventional Deadlift

Emily Ratajkowski Talks Game of Thrones and Awkward First Dates | 10 Firsts | InStyle

Emily Ratajkowski Talks Game of Thrones and Awkward First Dates | 10 Firsts | InStyle