List of videos

Pavlin Gergov - How async and await ended up in Python

How async and await ended up in Python [EuroPython 2018 - Talk - 2018-07-27 - Moorfoot] [Edinburgh, UK] By Pavlin Gergov We're going to talk about regular functions, iterables, iterators, function execution and yield - generator functions. We will send values and play with generators a bit. A quick look at asyncio will be followed by async and await, what a coroutine is and how to write async code with Python. 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://ep2018.europython.eu/en/speaker-release-agreement/

Watch
Neil Gall - System testing with Pytest, Docker, and Flask

System testing with Pytest, Docker, and Flask [EuroPython 2018 - Talk - 2018-07-27 - Moorfoot] [Edinburgh, UK] By Neil Gall The composability of fixtures in pytest is an improvement over traditional xUnit setup/teardown, reducing the incentive to commit testing crimes such as multi-stage and stepwise tests. This is great out of the box for unit tests, but I'm going to show how to combine the power of pytest fixtures with Docker to build high-level integration tests for microservices or other complex systems with multiple components. I'll then build on that to show how to embed mock web services written with Flask right into the test code. With a sample Java application that makes use of some external resources to offer a data processing service I'll first quick an overview of Pytest, Docker, and Flask. Then I'll mix some pre-built code with live test coding to demonstrate how to build high-level system tests which spin up the application and its dependencies in Docker. I'll then mock one of the external dependencies using Flask, allowing the test to control and verify interaction between the system components. Finally I'll show how to wrap the Flask application in a WSGI middleware that lets the test inspect interaction with the mocked service. From a learning and development point of view, building your own is better than re-using someone else's code so I'll show how the support code for these features is relatively simple and how the audience can build it themselves to exactly meet their own needs. And I'll do it all with a sense of fun, a joke or two and maybe a little storytelling. 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://ep2018.europython.eu/en/speaker-release-agreement/

Watch
Keith Harrison - Creating a Culture of Software Craftsmanship

Creating a Culture of Software Craftsmanship [EuroPython 2018 - Talk - 2018-07-27 - Moorfoot] [Edinburgh, UK] By Keith Harrison This time it’ll be different. It’s a green field project and you’ve learned from your mistakes. You’re not going to make the same ones again. Fast forward several months and you’re in a mess. A change in one place causes bugs in a completely different place. Adding a simple feature means making changes all over your application. Progress is getting slower and slower. You’re lost in complexity. Why does this keep happening and what can we do about it? This talk will try to answer those questions. I’ll show how complex software really is, define the different types of complexity found in software, explain the issues complexity causes and discuss different techniques we can use to manage it. This talk is suitable for anyone who has worked or will work on a software development project. No development experience is required. 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://ep2018.europython.eu/en/speaker-release-agreement/

Watch
Chase Stevens - Exploring the Python AST Ecosystem

Exploring the Python AST Ecosystem [EuroPython 2018 - Talk - 2018-07-27 - Moorfoot] [Edinburgh, UK] By Chase Stevens Materials are available at https://github.com/hchasestevens/europython-2018 This session will introduce attendees to Python's rich ecosystem of abstract syntax tree tooling and libraries, with an emphasis on practical applications in static analysis and metaprogramming. Attendees should be fully comfortable with Python syntax and semantics, but familiarity with the ast module itself will not be necessary. The talk will begin with a conceptual overview of ASTs, including a brief look at Python's built-in introspection capabilities. It will introduce tools for AST visualization (astor, showast, python-ast-explorer), creation (asttools, meta), and transformation to source code (codegen). How the AST can be used for static analysis will be covered; this will include discussion of Python's built-in facilities (NodeVisitor) as well as of the 3rd party tools astsearch, astpath, and bellybutton. The talk will demonstrate the advantages and limits of these tools in comparison to other static analysis tooling (pylint, mypy); particular attention will be paid to how these tools can be incorporated into attendees' workflows and existing codebases and projects. Tooling for Python AST manipulation and metaprogramming will be the final topic covered, focusing on the use of the NodeTransformer built-in. The talk will cover practical applications and examples of metaprogramming, such as metaprogramming for DSLS (pony, xpyth), runtime code manipulation (patterns, yield-from), and others (e.g. assertion rewriting in pytest). While the talk will touch only briefly on each of the applications discussed, by the end of the session attendees should have a firm grasp of the kinds of problems the AST can be used to solve, what existing AST tooling can accomplish, and what resources are available for the development of their own AST tools. 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://ep2018.europython.eu/en/speaker-release-agreement/

Watch
Andy Fundinger - A Taxonomy of Decorators: A E

A Taxonomy of Decorators: A-E [EuroPython 2018 - Talk - 2018-07-27 - Moorfoot] [Edinburgh, UK] By Andy Fundinger This talk will briefly go over the various decorator syntaxes before breaking up the common usages of decorators into 5 categories. Effectively, these are design patterns for decorators. The usages to be considered are: A - Argument Changing Decorators -- Decorators that change a function's arguments, including changing its signature B - Binding Decorators -- Decorators that implement the Descriptor Protocol, such as the builtins: @property, @classmethod, and @staticmethod C - Control Flow Decorators -- Decorators that change when or whether the function will be called, such as @retry or @lrucache D - Descriptive Decorators -- Decorators that do not change the function, but create a reference to it elsewhere, like pytest.mark and flask.app.route E - Execution Decorators -- Decorators that retrieve source code and/or AST and alter it. 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://ep2018.europython.eu/en/speaker-release-agreement/

Watch
Victor Stinner - Python 3: ten years later

Python 3: ten years later [EuroPython 2018 - Talk - 2018-07-27 - Lammermuir] [Edinburgh, UK] By Victor Stinner Draft of the talk: Growing populary of the Python programming language Defacto language in the scientific world, replacing other closed source and more specialized but limited language Favorite programming language used as the first language to learn programming Port Python 2 code to Python 3 Port Python 2 code to Python 3 No: "Add support for Python 3", don't loose Python 2 support Port Python 3 code to Python 2 Python changes to make the transition smoother: PEP 414: u"syntax" reintroduced in Python 3.3 PEP 461: bytes % args, Python 3.5 More "Py3k" warnings added to Python 2.7.x Linters like flake8 detect some issues six, futures, modernize, 2to6, etc. Analysis of the transition Good: At Pycon US 2014, Guido van Rossum announced that the Python 2.7 support was extended from 2015 to 2020 to give more time to companies to port their applications to Python 3. Bad: 2to3: "drop Python2 support at once", don't work when you have dependencies. If done again, would it be different? Yes, obviously. Python 4 will be different than Python 3: no more "break the world" release, but a "regular deprecation period" release, as any other release. Break things, one by one :-) Bugs that won't be fixed in Python 2 anymore Some bugs cannot be fixed without breaking the backward compatibility Unicode Support Python 2 I/O stack bugs: rely on libc stdio.h Security: hash DoS, enabled by default in Python 3.3, Python 3.4 now uses SipHash subprocess is not thread-safe in Python 2. Python 2 subprocess has many race conditions: fixed in Python 3 with a C implementation which has less or no race condition. Handling signals while forking in complex. threading.RLock is not "signal safe" in Python 2 Python 2 requires polling to wait for a lock or for I/O. Python 3 uses native threading API with timeout and has asyncio. Python 3 uses a monotonic clock to not crash on system clock update (ex: DST change). Python 3 has a better GIL. Python 2 inherits file descriptors on fork+exec by default. Python 3 don't: PEP 446. Functions can fail with OSError(EINTR) when interrupted by a signal, need to be very careful everywhere. SIGCHLD when a child process completes, SIGWINCH when using ncurses. Python 3.5 restarts the interrupted system call for you. Performance Python 3.6 is now faster than Python 2.7 https://speed.python.org/ Evolutions of the Python language Python 3.5 PEP 492: async/await "keywords" for asyncio. (Really keywords in Python 3.7.) PEP 461: bytes % args and bytearray % args PEP 465, a new matrix multiplication operator: a @ b. PEP 448: Generalized unpacking: head, *tail = list mylist = [1, 2, **other_list] mydict = {"key": "value", **other_dict} Python 3.6 PEP 515: million = 1_000_000 name = "World"; print(f"Hello {name}!") PEP 526, syntax for variable annotations. PEP 525, asynchronous generators. PEP 530: asynchronous comprehensions. Bury Python 2? "Python 3 only" https://pythonclock.org/ http://www.python3statement.org/ Fedora 23, Ubuntu 17.10: no python2 (/usr/bin/python) in the base system 2017, April: IPython 6.0 2017, December: Django 2 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://ep2018.europython.eu/en/speaker-release-agreement/

Watch
Sven Hendrik Haase - Rust and Python - Oxidize Your Snake

Rust and Python - Oxidize Your Snake [EuroPython 2018 - Talk - 2018-07-27 - Lammermuir] [Edinburgh, UK] By Sven-Hendrik Haase Rust is a safe and modern systems programming language that is easily able to call and be called from Python. As such, it is a prime candidate for replacing C for writing Python modules that have to be fast or that have to interact with other native code. Rust is extremely fast and makes it very hard to get concurrency wrong. Many ways of making Python call into lower level have appeared over the years such as CFFI, ctypes, boost.python, cython, SWIG. All of them are cumbersome in their own ways. PyO3 is a Rust library that makes it easy and simple to write native Python modules with minimal glue code and no crazy tooling required. It even works cross-platform without problems. The talk shows some sample code of PyO3-based modules and compares it with the code of the alternatives as well as the alternative's cross-platform support and tooling. The goal is for the audience to be informed about a new safe and modern way of writing native Python modules. The audience doesn't need any prerequisites except for a healthy interest in native code and Python modules. C knowledge is optional. 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://ep2018.europython.eu/en/speaker-release-agreement/

Watch
Paul Keating - Writing good error messages

Writing good error messages [EuroPython 2018 - Talk - 2018-07-27 - Lammermuir] [Edinburgh, UK] By Paul Keating Anyone who has ever conducted an elementary programming course, or even answered a question on StackOverflow, will know that reading error messages is a skill that beginners have to learn. It is less widely appreciated that writing good error messages is also a skill that must be learnt. This talk is in two parts. The first covers the commonest error message gaffes: • Insufficiently explicit messages. • Issuing the same message for two different conditions. • Suppressing the stack trace. • Polluting the stack trace. The second part describes a way to ensure usable, actionable error messages, even when the writer of the message is not a professional coder. This was developed for an environment where superusers code up most of the dozens of data validation rules and the accompanying messages, and the application in which Python is embedded suppresses the stack trace. 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://ep2018.europython.eu/en/speaker-release-agreement/

Watch
Emmanuelle Delescolle - A tale of refactoring

A tale of refactoring [EuroPython 2018 - Talk - 2018-07-27 - Lammermuir] [Edinburgh, UK] By Emmanuelle Delescolle A couple years ago I was approached by a client to help them improve the performance and maintainability of their code. That code was filled with very long functions, some of them with very similar code and the project was really hard to understand as a whole. My first reflex was to refactor this code code to make it more understandable. In my opinion, it did fit part of my assignment as understandable code is easier to maintain but it was also very helpful later in letting me make small changes with full knowledge of what was going to be affected by those changes. Large methods and functions is something that creeps into our code whether we plan for it or not. This talk is about one way to deal with it. This talk will be based on code provided by the GildedRose Refcatoring Kata: https://github.com/emilybache/GildedRose-Refactoring-Kata Prerequisites: - Basic knowledge of Python - Basic knowledge of OOP Goals: - Demonstrate one approach for refactoring code - Show how to leverage Python's dynamic nature to make code simpler 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://ep2018.europython.eu/en/speaker-release-agreement/

Watch