Slide 1

Slide 1 text

AUSTIN PYTHON MEETUP AUGUST 2018

Slide 2

Slide 2 text

HI, I'M DUSTIN

Slide 3

Slide 3 text

PEP 572

Slide 4

Slide 4 text

PYTHON GOVERNANCE

Slide 5

Slide 5 text

BDFL BENEVOLENT DICTATOR FOR LIFE

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

PEP PYTHON ENHANCEMENT PROPOSAL

Slide 8

Slide 8 text

PEP 8 STYLE GUIDE FOR PYTHON CODE

Slide 9

Slide 9 text

PEP 8 STYLE GUIDE FOR PYTHON CODE AUTHOR: GUIDO VAN ROSSUM

Slide 10

Slide 10 text

PEP 20 THE ZEN OF PYTHON

Slide 11

Slide 11 text

PEP 20 THE ZEN OF PYTHON AUTHOR: TIM PETERS

Slide 12

Slide 12 text

PEP 566 METADATA FOR PYTHON SOFTWARE PACKAGES 2.1

Slide 13

Slide 13 text

PEP 566 METADATA FOR PYTHON SOFTWARE PACKAGES 2.1 AUTHOR: DUSTIN INGRAM

Slide 14

Slide 14 text

BDFL DELEGATES

Slide 15

Slide 15 text

1) DRAFT 2) ACCEPTANCE 3) IMPLEMENTATION

Slide 16

Slide 16 text

PEP 572

Slide 17

Slide 17 text

:=

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

PROBLEMS

Slide 21

Slide 21 text

match = pattern.search(data) if match is not None: do_something(match)

Slide 22

Slide 22 text

chunk = file.read(8192) while chunk: process(chunk) chunk = file.read(8192)

Slide 23

Slide 23 text

foo = [f(x), f(x)**2, f(x)**3]

Slide 24

Slide 24 text

y = f(x) foo = [y, y**2, y**3]

Slide 25

Slide 25 text

results = [] for x in data: result = f(x) if result is not None: results.append(result)

Slide 26

Slide 26 text

filtered_data = [ f(x) for x in data if f(x) is not None ]

Slide 27

Slide 27 text

SOLUTIONS

Slide 28

Slide 28 text

match = pattern.search(data) if match is not None: do_something(match)

Slide 29

Slide 29 text

if (match := pattern.search(data)) is not None: do_something(match)

Slide 30

Slide 30 text

chunk = file.read(8192) while chunk: process(chunk) chunk = file.read(8192)

Slide 31

Slide 31 text

while chunk := file.read(8192): process(chunk)

Slide 32

Slide 32 text

foo = [f(x), f(x)**2, f(x)**3]

Slide 33

Slide 33 text

foo = [y := f(x), y**2, y**3]

Slide 34

Slide 34 text

results = [] for x in data: result = f(x) if result is not None: results.append(result)

Slide 35

Slide 35 text

filtered_data = [ f(x) for x in data if f(x) is not None ]

Slide 36

Slide 36 text

filtered_data = [ y for x in data if (y := f(x)) is not None ]

Slide 37

Slide 37 text

WHY?

Slide 38

Slide 38 text

LESS LINES ARE BETTER

Slide 39

Slide 39 text

foo = [y := f(x), y**2, y**3]

Slide 40

Slide 40 text

y = f(x) foo = [y, y**2, y**3]

Slide 41

Slide 41 text

LESS LINES ARE MORE EFFICIENT?

Slide 42

Slide 42 text

match = re.match(data) group = match.group(1) if match else None

Slide 43

Slide 43 text

group = re.match(data).group(1) if re.match(data) else None

Slide 44

Slide 44 text

group = match.group(1) if (match := re.match(data)) else None

Slide 45

Slide 45 text

SCOPE

Slide 46

Slide 46 text

foo = 'foo' if (foo := 'bar') is not None: do_something(...) print(foo)

Slide 47

Slide 47 text

EXCEPTIONS!

Slide 48

Slide 48 text

if any((comment := line).startswith('#') for line in lines): print("First comment:", comment) else: print("There are no comments")

Slide 49

Slide 49 text

if all((nonblank := line).strip() == '' for line in lines): print("All lines are blank") else: print("First non-blank line:", nonblank)

Slide 50

Slide 50 text

total = 0 partial_sums = [total := total + v for v in values] print("Total:", total)

Slide 51

Slide 51 text

=

Slide 52

Slide 52 text

x = y = z = 0 # Yes (z := (y := (x := 0))) # No

Slide 53

Slide 53 text

a[i] = x # Yes a[i] := x # No self.rest = [] # Yes self.rest := [] # No

Slide 54

Slide 54 text

x = 1, 2 # Sets x to (1, 2) (x := 1, 2) # Sets x to 1

Slide 55

Slide 55 text

total += tax # Yes total +:= tax # No

Slide 56

Slide 56 text

= VS. ==

Slide 57

Slide 57 text

PEP 572

Slide 58

Slide 58 text

RECEPTION

Slide 59

Slide 59 text

BACKWARDS COMPATIBILITY "WHERE WILL THIS WORK?"

Slide 60

Slide 60 text

TEACHABILITY "WHAT DO WE CALL THIS?"

Slide 61

Slide 61 text

ATTRACTIVENESS "IT'S JUST UGLY!"

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

No content

Slide 66

Slide 66 text

TIM PETERS: "THE CURRENT PROPOSAL WOULD HAVE ALLOWED A MODEST BUT CLEAR IMPROVEMENT IN QUITE A FEW BITS OF CODE."

Slide 67

Slide 67 text

BARRY WARSAW: "SINCE IT CHANGES THE SYNTAX OF THE LANGUAGE, PEOPLE TEND TO FOCUS ON THAT WITHOUT UNDERSTANDING THE DEEPER SEMANTIC ISSUES."

Slide 68

Slide 68 text

ŁUKASZ LANGA: "DICTATORS SHOULD DICTATE"

Slide 69

Slide 69 text

GUIDO VAN ROSSUM: HAD TO STOP READING THE THREADS SO HE WOULDN'T "GO INSANE"

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

QUESTIONS

Slide 73

Slide 73 text

WHAT DOES THIS MEAN FOR PYTHON?

Slide 74

Slide 74 text

IT'S GOING TO BE OK

Slide 75

Slide 75 text

WILL THIS BECOME PART OF PYTHON?

Slide 76

Slide 76 text

PROBABLY (IN 3.8)

Slide 77

Slide 77 text

BUT I DON'T LIKE IT!

Slide 78

Slide 78 text

THEN DON'T WRITE IT!

Slide 79

Slide 79 text

IS GUIDO COMING BACK?

Slide 80

Slide 80 text

PROBABLY NOT

Slide 81

Slide 81 text

WILL THIS HAPPEN AGAIN?

Slide 82

Slide 82 text

PROBABLY NOT

Slide 83

Slide 83 text

¯\_(ϑ)_/¯

Slide 84

Slide 84 text

THANKS!