Cover image of Python Bytes
(105)

Rank #42 in Technology category

Technology
Software How-To

Python Bytes

Updated 14 days ago

Rank #42 in Technology category

Technology
Software How-To
Read more

Python Bytes is a weekly podcast hosted by Michael Kennedy and Brian Okken. The show is a short discussion on the headlines and noteworthy news in the Python, developer, and data science space.

Read more

Python Bytes is a weekly podcast hosted by Michael Kennedy and Brian Okken. The show is a short discussion on the headlines and noteworthy news in the Python, developer, and data science space.

iTunes Ratings

105 Ratings
Average Ratings
96
4
3
1
1

Great Python info

By alltheothernamesweretaken54136 - Dec 18 2018
Read more
Great way to keep up with the goings-on in Python.

Perfect for the morning commute.

By DangerFarr - Sep 13 2018
Read more
A quick & efficient way to keep up with news and development in the Python space!

iTunes Ratings

105 Ratings
Average Ratings
96
4
3
1
1

Great Python info

By alltheothernamesweretaken54136 - Dec 18 2018
Read more
Great way to keep up with the goings-on in Python.

Perfect for the morning commute.

By DangerFarr - Sep 13 2018
Read more
A quick & efficient way to keep up with news and development in the Python space!
Cover image of Python Bytes

Python Bytes

Updated 14 days ago

Rank #42 in Technology category

Read more

Python Bytes is a weekly podcast hosted by Michael Kennedy and Brian Okken. The show is a short discussion on the headlines and noteworthy news in the Python, developer, and data science space.

Rank #1: #142 There's a bandit in the Python space

Podcast cover
Read more

Special guest: Brett Thomas

Sponsored by Datadog: pythonbytes.fm/datadog

Brian #1: Writing sustainable Python scripts

  • Vincent Bernat
  • Turning a quick Python script into a maintainable bit of software.
  • Topics covered:
    • Documentation as a docstring helps future users/maintainers know what problem you are solving.
    • CLI arguments with defaults instead of hardcoded values help extend the usability of the script.
    • Logging. Including debug logging (and how to turn them on with CLI arguments), and system logging for unattended scripts.
    • Tests. Simple doctests, and pytest tests utilizing parametrize to have one test and many test cases.

Brett #2: Static Analysis and Bandit

Michael #3: jupyter-black

  • Black formatter for Jupyter Notebook
  • One of the big gripes I have about these online editors is their formatting (often entirely absent)
  • Then the extension provides
    • a toolbar button
    • a keyboard shortcut for reformatting the current code-cell (default: Ctrl-B)
    • a keyboard shortcut for reformatting whole code-cells (default: Ctrl-Shift-B)

Brian #4: Report Generation workflow with papermill, jupyter, rclone, nbconvert, …

Brett #5: Rant on time deltas

Michael #6: How — and why — you should use Python Generators

  • by Radu Raicea
  • Generator functions allow you to declare a function that behaves like an iterator.
  • They allow programmers to make an iterator in a fast, easy, and clean way.
  • They only compute it when you ask for it. This is known as lazy evaluation.
  • If you’re not using generators, you’re missing a powerful feature
  • Often they result in simpler code than with lists and standard functions

Extras

Brian:

Michael:

Jokes

A good programmer is someone who always looks both ways before crossing a one-way street.

(reminds me of another joke: Adulthood is like looking both ways before crossing the street, then getting hit by an airplane)

Little bobby tables

Aug 06 2019
30 mins
Play

Rank #2: #141 Debugging with f-strings coming in Python 3.8

Podcast cover
Read more

Sponsored by Datadog: pythonbytes.fm/datadog

Brian #1: Debugging with f-strings in Python 3.8

  • We’ve talked about the walrus operator, :=, but not yet “debug support for f-strings”
  • this: print(f'foo={foo} bar={bar}')
  • can change to this: print(f'{foo=} {bar=}')
  • and if you don’t want to print with repr() you can have str() be used with !s.
    • print(f'{foo=!s} {bar=!s}')
  • also !f can be used for float modifiers:
>>> import math
>>> print(f'{math.pi=!f:.2f}')
math.pi=3.14
  • one more feature, space preservation in the f-string expressions:
>>> a = 37
>>> print(f'{a = }, {a = }')
a = 37, a = 37

Michael #2: Am I "real" software developer yet?

  • by Sun-Li Beatteay
  • To new programmers joining the field, especially those without CS degrees, it can feel like the title is safe-guarded. Only bestowed on the select that have proven themselves.
  • Sometimes manifests itself as Impostor Syndrome
  • Focused on front-end development as I had heard that HTML, CSS and JavaScript were easy to pick up
  • That was when I decided to create a portfolio site for my wife, who was a product designer.
  • Did my best to surround myself with tech culture.
    • Watched YouTube videos
    • listened to podcasts
    • read blog posts from experienced engineers to keep myself motivated.
    • Daydreamed what it would be like to stand in their shoes.
  • My wife’s website went live in July of that year. I had done it.
  • Could I finally start calling myself something of a Software Engineer?
    • “Web development isn’t real programming”
  • Spent the next 18 months studying software development full time. I quit my job and moved in with my in-laws — which was a journey in-and-of itself.
    • Software engineer after 1-2 years? No so fast (says the internet)
  • The solution that I found for myself was simple yet terrifying: talking to people
  • MK: BTW, I don’t really like the term “engineer”

Brian #3: Debugging with local variables and snoop

  • debugging tools
  • ex: “You want to know which lines are running and which aren't, and what the values of the local variables are.”
    • Throw a @snoop decorator on a function and the function lines and local variable values will be dumped to stderr during run. Even showing loops a bunch of times.
  • It’s tools to almost debug as if you had a debugger, without a debugger, and without having to add a bunch of logging or print statements.
  • Lots of other use models to allow more focus.
    • wrap just part of your function with a with snoop block
    • only watch certain local variables.
    • turn off reporting for deep function/block levels.

Michael #4: New home for Humans

  • This came out of the blue with some trepidation:
  • kennethreitz commented 6 days ago:

In the spirit of transparency, I'd like to (publicly) find a new home for my repositories. I want to be able to still make contributions to them, but no longer be considered the "owner" or "arbiter" or "BDFL" of these repositories.

Some notable repos:

Brian #5: The Backwards Commercial License

  • Eran Hammer - open source dev, including hapi.js
  • Interesting idea to make open source projects maintainable
  • Three phases of software lifecycle for some projects:
    • first: project created to fill a need in one project/team/company, a single use case
    • second: used by many, active community, growing audience
    • three: work feels finished. bug fixes, security issues, minor features continue, but most people can stay on old stable versions
  • During the “done” phase, companies would like to have bug fixes but don’t want to have to keep changing their code to keep up.
  • Idea: commercial license to support old stable versions.
    • “If you keep up with the latest version, you do not require a license (unless you want the additional benefits it will provide).”
    • “However, very few companies can quickly migrate every time there is a new major release of a core component. Engineering resources are limited and in most cases, are better directed at building great products than upgrading supporting infrastructure. The backwards license provides this exact assurance. You can stay on any version you would like knowing that you are still running supported, well-maintained, and secure code.”
    • “The new commercial license will include additional benefits focused on providing enterprise customers the assurances needed to rely on these critical components for many years to come. “

Michael #6: Switching Python Parsers?

  • via Gi Bi, article by Guido van Rossum
  • Alternative to the home-grown parser generator that I developed 30 years ago when I started working on Python. (That parser generator, dubbed “pgen”, was just about the first piece of code I wrote for Python.)
  • Here are some of the issues with pgen that annoy me.
    • The “1” in the LL(1) moniker implies that it uses only a single token lookahead, and this limits our ability of writing nice grammar rules.
    • Because of the single-token lookahead, the parser cannot determine whether it is looking at the start of an expression or an assignment.
  • So how does a PEG parser solve these annoyances? By using an infinite lookahead buffer!
  • The typical implementation of a PEG parser uses something called “packrat parsing”, which not only loads the entire program in memory before parsing it, but also allows the parser to backtrack arbitrarily.
  • Why not sooner? Memory! But that is much less of an issue now.
  • My idea now, putting these things together, is to see if we can create a new parser for CPython that uses PEG and packrat parsing to construct the AST directly during parsing, thereby skipping the intermediate parse tree construction, possibly saving memory despite using an infinite lookahead buffer

Extras

Brian:

Michael:

Jokes

A couple of quick ones:

  • “What is a whale’s favorite language?” “C” — via Eric Nelson
  • Why does Pythons live on land? Because it is above C-level! — via Jesper Kjær Sørensen @JKSlonester
Jul 29 2019
30 mins
Play

Rank #3: #49 Your technical skills are obsolete: now what?

Podcast cover
Read more

Sponsored by DigitalOcean. They just launched Spaces, get started today with a free 2 month trial of Spaces by going to do.co/python

Brian #1: Conference videos for DjangoCon 2017 and PyGotham 2017

Michael #2: Python 3.6.3 released on Tue. All machines at FB are already running it (3 days)

  • Tweet: Did you hear that 3.6.3 was released on Tue? How about that all machines at FB are already running it? Over 36.3% of our Python apps are 3.6 via @llanga
  • See Jason Fried’s presentation on culture: Rules for Radicals: Changing the Culture of Python at Facebook
  • More Python 3 news
    • Ubuntu 17.10: “Python 2 is no longer installed by default. Python 3 has been updated to 3.6.”
    • PSA: Python 3.3 is end-of-life in 2 days. Are you prepared?

Brian #3: Your technical skills are obsolete: now what?

  • by Itamar Turner-Trauring
  • We’re big proponents of keeping your skills current, of learning new techniques and technologies. But how does that fit in with life and work.
  • This article is an opinion of how to work on new skills while at work, do it quickly, and look good to your manager.
  • It starts with a good discussion of real business reasons why some projects use older technology. Basically, cost vs benefit of change.
  • Steps to be part of the solution:
    • Identify obsolete and problematic technologies.
    • Identify potential replacements.
    • Get management buy in to get resources (you) to do a pilot project exploring new technology.
  • This process will help you be better at identifying problems, even if you don’t get approval to fix it.
  • He ends with a comment that if you don’t get approval, all is not lost, you have skills to apply to a new job.
  • I’d like to make sue you do a few more steps before giving up and looking for a new job. Before you consider a move to a new team or company, I think…
    • You should give your manager the benefit of the doubt and use this to start a conversation. Make sure you understand their reasons for saying no.
    • Make sure you are not proposing too much time taken away from your primary role in the company.
    • State that you want to improve your skills by providing value for the team and the company.
    • Is the “no” due to just bad timing? Is there a higher priority problem to work on?
    • You’ve just shown that you are someone interested in keeping your skills sharp and helping the company by expanding your role. If you’re still stuck at this point, then consider a move but also, …
  • Read this:
    • Team Geek: A Software Developer's Guide to Working Well with Others - Brian Fitzpatrick
    • Especially:
      - pg 117 : “Offensive vs Defensive work”. 50-70% of your time at work needs to be focused on creating new value for your company or your customers. No more than 30-50% on repaying technical debt. (Okken: Limit your process improvement / new technology exploration to no more than 10-20%, but try to never drop it below 5% of your time)
      - pg 113 : “It’s easier to ask for forgiveness than permission.” This is a fine line between doing the right thing and doing something you can get reprimanded for. Use good judgement.
      - Forgotten page number: A big part of your job is making your boss’s job easier and making your boss and your team look good.

Michael #4: Visualizing Garbage Collection Algorithms

  • By Ken Fox
  • Follow up from the excellent deep dive article in GC from Brian
  • Most developers take automatic garbage collection for granted.
  • It’s very difficult to see how GCs actually work.
  • GCs visualized (click on each image):
    • Cleanup At The End: aka No GC (e.g. Apache web server creates a small pool of memory per request and throws the entire pool away when the request completes)
    • Reference Counting Collector (e.g. Python’s first pass GC, Microsoft COM, C++ Smart Pointers. Memory fragmentation is interesting)
      • The red flashes indicate reference counting activity. A very useful property of reference counting is that garbage is detected as soon as possible — you can sometimes see a flash of red immediately followed by the area turning black.
    • Mark-Sweep Collector (e.g. is this Python’s secondary collector? Probably is my guess)
      • Mark-sweep eliminates some of the problems of reference count. It can easily handle cyclic structures and it has lower overhead since it doesn’t need to maintain counts.
    • Mark-Compact Collector (Oracle’s Hotspot JVM’s tenured object space uses mark-compact)
      • Mark-compact disposes of memory, not by just marking it free, but by moving objects down into the free space
      • The crazy idea of moving objects means that new objects can always just be created at the end of used memory. This is called a “bump” allocator and is as cheap as stack allocation, but without the limitations of stack size.
    • Copying Collector, aka Generational GC
      • The foundation of most high-performance garbage collection systems

Brian #5: pathlib — Filesystem Paths as Objects

  • from Doug Hellman’s PyMOTW-3
  • pathlib was introduced with Python 3.4
  • If you need to work with the file system in Python, you should be using pathlib.
  • Doug’s article is a really good overview.
  • Features
    • Building paths with overloaded / operator
    • Parsing paths with .parts, .parents, .suffix, .stem
    • Concrete paths such as Path.home(), Path.cwd()
    • Getting directory contents with .iterdir()
    • Pattern matching with .glob() and .rglob()
    • Reading and writing files with path objects.
    • Working with directories and symbolic links
    • File properties, permissions
    • Deleting files and directories
  • see also

Michael #6: LUMINOTH: Open source Computer Vision toolkit

  • Deep Learning toolkit for Computer Vision
  • Supports object detection and image classification, but are aiming for much more.
  • It is built in Python, using TensorFlow and Sonnet (Google’s Deep Learning framework and DeepMind’s graph library)
  • Easily train neural networks to detect and classify objects with custom data.
  • Use state of the art models such as Faster R-CNN (Region-based Convolutional Neural Networks)
  • Comes with GPGPU support
  • Simple training
    • Train your model by just typing lumi train. Do it locally or using Luminoth's built-in Google Cloud Platform support to train in the cloud.
    • Once training is done, you can use our Tensorboard integration to visualize progress and intermediate results.
  • Are also working on providing pre-trained checkpoints on popular datasets such as Pascal VOC2012

Bonus article:

The Cleaning Hand of Pytest - My experiences with different approaches to testing

  • by Wiktor Żurawik
  • Two case studies of having to use unittest after using pytest
  • Be sure to check out the “useful links” at the end of the article.

Our news

Oct 25 2017
25 mins
Play

Rank #4: #112 Don't use the greater than sign in programming

Podcast cover
Read more

Sponsored by https://pythonbytes.fm/datadog

Brian #1: nbgrader

  • nbgrader: A Tool for Creating and Grading Assignments in the Jupyter Notebook
    • The Journal of Open Source Education, paper accepted 6-Jan-2019
  • nbgrader documentation, including a intro video
  • From the JOSE article:
    • “nbgrader is a flexible tool for creating and grading assignments in the Jupyter Notebook (Kluyver et al., 2016). nbgrader allows instructors to create a single, master copy of an assignment, including tests and canonical solutions. From the master copy, a student version is generated without the solutions, thus obviating the need to maintain two separate versions. nbgrader also automatically grades submitted assignments by executing the notebooks and storing the results of the tests in a database. After auto-grading, instructors can manually grade free responses and provide partial credit using the formgrader Jupyter Notebook extension. Finally, instructors can use nbgrader to leave personalized feedback for each student’s submission, including comments as well as detailed error information.”
  • CS teaching methods have come a long ways since I was turning in floppies and code printouts.
Michael #2: profanity-check

  • A fast, robust Python library to check for offensive language in strings.
  • profanity-check uses a linear SVM model trained on 200k human-labeled samples of clean and profane text strings.
  • Making profanity-check both robust and extremely performant
  • Other libraries like profanity-filter use more sophisticated methods that are much more accurate but at the cost of performance.
    • profanity-filter runs in 13,000ms vs 24ms for profanity-check in a benchmark
  • Two ways to use:
    • predict(text) → 0 or 1 (1 = bad)
    • predict_prob(text) → [0, 1] confidence interval (1 = bad)
Brian #3: An Introduction to Python Packages for Absolute Beginners

  • Ever tried to explain the difference between module and package? Between package-in-the-directory-with-init sense and package-you-can-distribute-and-install-with-pip sense? Here’s the article to read beforehand.
  • Modules, packages, using packages, installing, importing, and more.
  • And that’s not even getting into flit and poetry, etc. But it’s a good place to start for people new to Python.
Michael #4: Python Dependencies and IoC

  • via Joscha Götzer
  • Open-closed principle is at work with these and is super valuable to testing (one of the SOLID principles): Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification.
  • There is a huge debate around why Python doesn’t need DI or Inversion of Control (IoC), and a quick stackoverflow search yields multiple results along the lines of “python is a scripting language and dynamic enough so that DI/IoC makes no sense”. However, especially in large projects it might reduce the cognitive load and decoupling of individual components
  • Dependency Injector: I couldn’t get this one to work on windows, as it needs to compile some C libraries and some Visual Studio tooling was missing that I couldn’t really install properly. The library looks quite promising though, but sort of static with heavy usage of containers and not necessarily pythonic.
  • Injector: The library that above mentioned article talks about, a little Java-esque
  • pinject: Has been unmaintained for about 5 years, and only recently got new attention from some open source people who try to port it to python3. A product under Google copyright, and looks quite nice despite the lack of python3 bindings. Probably the most feature-rich of the listed libraries.
  • python-inject: I discovered that one while writing this email, not really sure if it’s any good. Nice use of type annotations and testing features
  • di-py: Only works up to python 3.4, so I’ve also never tried it (I’m one of those legacy python haters, I’m sure you can relate 😄).
  • Serum: This one is a little too explicit to my mind. It makes heavy use of context managers (literally with Context(...): everywhere 😉) and I’m not immediately sure how to work with it. In this way, it is quite powerful though. Interesting use of class decorators.
  • And now on to my favorite and a repeated recommendation of mine around the internet→ Haps: This lesser-known, lightweight library is sort of the new kid on the block, and really simple to use. As some of the other libraries, it uses type annotations to determine the kind of object it is supposed to instantiate, and automatically discovers the required files in your project folder. Haps is very pythonic and fits into apps of any size, helping to ensure modularization as the only dependency of your modules will be one of the types provided by the library. Pretty good example here.
Brian #5: A Gentle Introduction to Pandas

  • Really a gentle introduction to the Pandas data structures Series and DataFrame.
  • Very gentle, with console examples.
  • Create series objects:
    • from an array
    • from an array, and change the indexing
    • from a dictionaries
    • from a scalar, cool. didn’t know you could do that
  • Accessing elements in a series
  • DataFrames
    • sorting, slicing
    • selecting by label, position
    • statistics on columns
    • importing and exporting data
Michael #6: Don't use the greater than sign in programming

  • One simple thing that comes up time and time again is the use of the greater than sign as part of a conditional while programming. Removing it cleans up code.
  • Let's say that I want to check that something is between 5 and 10.
  • There are many ways I can do this
x > 5 and 10 > x
5 < x and 10 > x
x > 5 and x < 10
10 < x and x < 5
x < 10 and x > 5
x < 10 and 5 < x
  • Sorry, one of those is incorrect. Go ahead and find out which one
  • If you remove the use of the greater than sign then only 2 options remain
    • x < 10 and 5 < x
    • 5 < x and x < 10
    • The last is nice because x is literally between 5 and 10
  • There is also a nice way of expressing that "x is outside the limits of 5 and 10”
    • x < 5 or 10 < x
    • Again, this expresses it nicely because x is literally outside of 5 to 10.
  • Interesting comment: What is cleaner or easier to read comes down to personal taste. But how to express "all numbers greater than 1" without '>'?
    • ans: 1 < allNumbers
Extras

Michael

Joke: Harry Potter Parser Tongue via Nick Spirit

Jan 11 2019
28 mins
Play

Rank #5: #102 Structure of a Flask Project

Podcast cover
Read more

Sponsored by DigitalOcean: pythonbytes.fm/digitalocean

Brian #1: QuantEcon

  • “Open source code for economic modeling”
  • “QuantEcon is a NumFOCUS fiscally sponsored project dedicated to development and documentation of modern open source computational tools for economics, econometrics, and decision making.”
  • Educational resource that includes:
    • Lectures, workshops, and seminars
    • Cheatsheets for scientific programming in Python and Julia
    • Notebooks
    • QuantEcon.py : open source Python code library for economics

Michael #2: Structure of a Flask Project

  • Flask is very flexible, it has no certain pattern of a project folder structure. Here are some suggestions.
  • I always keep this one certain rule when writing modules and packages:
  • Candidate structure:
project/
__init__.py
models/
__init__.py users.py posts.py
...
routes/
__init__.py home.py account.py dashboard.py
...
templates/
base.html
post.html
...
services/
__init__.py google.py mail.py
  • Love it! To this, I would rename routes to views or controllers and add a viewmodels folder and viewmodels themselves.
  • Brian, see anything missing?
    • ya. tests. :)
  • Another famous folder structure is app based structure, which means things are grouped bp application
  • I (Michael) STRONGLY recommend Flask blueprints

Brian #3: Overusing lambda expressions in Python

  • lambda expressions vs defined functions
    1. They can be immediately passed around (no variable needed)
    2. They can only have a single line of code within them
    3. They return automatically
    4. They can’t have a docstring and they don’t have a name
    5. They use a different and unfamiliar syntax
  • misuses:
    • naming them. Just write a function instead
    • calling a single function with a single argument : just use that func instead
  • overuse:
    • if they get complex, even a little bit, they are hard to read
    • has to be all on one line, which reduces readibility
    • map and filter : use comprehensions instead
    • using custom lambdas instead of using operators from the operator module.

Michael #4: Asyncio in Python 3.7

  • by Cris Medina
  • The release of Python 3.7 introduced a number of changes into the async world.
    • Some may even affect you even if you don’t use asyncio.
  • New Reserved Keywords: The async and await keywords are now reserved.
    • There’s already quite a few modules broken because of this. However, the fix is easy: rename any variables and parameters.
  • Context Variables: Version 3.7 now allows the use of context variables within async tasks. If this is a new concept to you, it might be easier to picture it as global variables whose values are local to the currently running coroutines.
  • Python has similar constructs for doing this very thing across threads. However, those were not sufficient in async-world
  • New asyncio.run() function
    • With a call to asyncio.run(), we can now automatically create a loop, run a task on it, and close it when complete.
  • Simpler Task Management: Along the same lines, there’s a new asyncio.create_task() function that helps make tasks that inside the current loop, instead of having to get the loop first and calling create task on top of it.
  • Simpler Event Loop Management: The addition of asyncio.get_running_loop() will help determine the active event loop, and catch a RuntimeError if there’s no loop running.
  • Async Context Managers: Another quality-of-life improvement. We now have the asynccontextmanager() decorator for producing async context managers without the need for a class that implements __aenter__() or __aexit__().
  • Performance Improvements: Several functions are now optimized for speed, some were even reimplemented in C. Here’s the list:
    • asyncio.get_event_loop() is now 15 times faster.
    • asyncio.gather() is 15% faster.
    • asyncio.sleep() is two times faster when the delay is zero or negative.
    • asyncio.Future callback management is optimized.
    • Reduced overhead for asyncio debug mode.
  • Lots lots more

Brian #5: Giving thanks with **pip thank**

Michael #6: Getting Started With Testing in Python

  • by Anthony Shaw, 33 minutes reading time according to Instapaper
  • Automated vs. Manual Testing
  • Unit Tests vs. Integration Tests: A unit test is a smaller test, one that checks that a single component operates in the right way. A unit test helps you to isolate what is broken in your application and fix it faster.
  • Compares unittest, nose or nose2, pytest
  • Covers things like:
    • Writing Your First Test
    • Where to Write the Test
    • How to Structure a Simple Test
    • How to Write Assertions
    • Dangers of Side Effects
  • Testing in PyCharm and VS Code
  • Testing for Web Frameworks Like Django and Flask
  • Advanced Testing Scenarios
  • Even: Testing for Security Flaws in Your Application

Extras:

Oct 31 2018
26 mins
Play

Rank #6: #117 Is this the end of Python virtual environments?

Podcast cover
Read more

Sponsored by pythonbytes.fm/datadog

Brian #1: Goodbye Virtual Environments?

  • by Chad Smith
  • venv’s are great but they introduce some problems as well:
    • Learning curve: explaining “virtual environments” to people who just want to jump in and code is not always easy
    • Terminal isolation: Virtual Environments are activated and deactivated on a per-terminal basis
    • Cognitive overhead: Setting up, remembering installation location, activating/deactivating
  • PEP 582 — Python local packages directory
    • This PEP proposes to add to Python a mechanism to automatically recognize a __pypackages__directory and prefer importing packages installed in this location over user or global site-packages. This will avoid the steps to create, activate or deactivate “virtual environments”. Python will use the __pypackages__ from the base directory of the script when present.
  • Try it now with pythonloc
    • pythonloc is a drop in replacement for python and pip that automatically recognizes a __pypackages__ directory and prefers importing packages installed in this location over user or global site-packages. If you are familiar with node, __pypackages__ works similarly to node_modules.
    • Instead of running python you run pythonloc and the __pypackages__ path will automatically be searched first for packages. And instead of running pip you run piploc and it will install/uninstall from __pypackages__.

Michael #2: webassets

  • Bundles and minifies CSS & JS files
  • Been doing a lot of work to rank higher on the sites
  • That lead me to Google’s Lighthouse
  • Despite 25ms response time to the network, Google thought my site was “kinda slow”, yikes!
  • webassets has integration for the big three: Django, Flask, & Pyramid.
    • But I prefer to just generate them and serve them off disk
def build_asset(env: webassets.Environment,
files: List[str],
filters: str,
output: str):
bundle = webassets.Bundle(
*files,
filters=filters,
output=output,
env=env
)
bundle.build(force=True)

Brian #3: Bernat on Python Packaging

Michael #4: What the mock? — A cheatsheet for mocking in Python

  • Nice introduction
  • Some examples
@mock.patch('work.os')
def test_using_decorator(self, mocked_os):
work_on()
mocked_os.getcwd.assert_called_once()

And

def test_using_context_manager(self):
with mock.patch('work.os') as mocked_os:
work_on()
mocked_os.getcwd.assert_called_once()

Brian #5: Transitions: The easiest way to improve your tech talk

  • By Saron Yitbarek
  • Jeff Atwood of CodingHorror noted “The people who can write and communicate effectively are, all too often, the only people who get heard. They get to set the terms of the debate.”
  • Effectively presenting is part of effective communication.
  • I love the focus of this article. Focused on one little aspect of improving the performance of a tech talk.

Michael #6: Steering council announced

  • Our new leaders are
    • Barry Warsaw
    • Brett Cannon
    • Carol Willing
    • Guido van Rossum
    • Nick Coghlan
  • Via Joe Carey
  • We both think it’s great Guido is on the council.

From the list from Ant, my votes.

  • Q: What's the second movie about a database engineer called?
    A: The SQL.

  • !false
    It's funny 'cause it's true.

  • A programmer's spouse tells them, "Run to the store and pick up a loaf of bread. If they have eggs, get a dozen."
    The programmer comes home with 12 loaves of bread.

Feb 14 2019
28 mins
Play

Rank #7: #74 Contributing to Open Source effectively

Podcast cover
Read more

Sponsored by Datadog: pythonbytes.fm/datadog

Special guest: Matt Harrison - __mharrison__

Brian #1: Contributing to Open Source effectively
The mechanics and conventions on how to contribute to open source projects can be confusing. After seeing a very well documented pull request that started with [WIP] in the subject line when it was first submitted, I tried to find out more about the conventions and mechanics of it all. I’m still learning, but here are a couple of resources:

  • How to write the perfect pull request is more of a mindset of how to initiate and receive PRs
    • Approach to writing a Pull Request, including that [WIP] trick.
    • Offering feedback
    • Responding to feedback
  • Forge Your Future with Open Source, @vmbrasseur book on contributing to open source, includes:
    • Make a Contribution, which includes PRs
    • Make a difference without making a pull request, which is suggests many ways to contribute to a project without contributing code, like reviewing others contributions, testing, triaging bugs, …
    • Interacting with the community.

Matt #2: Jupyter, Mathematica, and the Future of the Research Paper

  • Paul Romer, economy professor at NYU
  • As a longtime Linux user there was constantly the question of the “year of the Linux Desktop”. Maybe this is the year of the “Jupyter desktop” (also beta version of JupyterLab). Not just a tool for innovators or early adopters
  • Refers to Article in Atlantic contrasting Mathematica and Jupyter: open-source developers have flocked to Python because it happens to be the de facto standard for scientific computing. Programming-language communities, like any social network, thrive—or die—on the strength of these feedback loops. https://www.theatlantic.com/science/archive/2018/04/the-scientific-paper-is-obsolete/556676/

Quotes:

Jupyter is a new open-source alternative [to Mathmatica] that is well on the way to becoming a standard for exchanging research results.

Python libraries let me replicate everything I wanted to do with Mathematica: Matplotlib for graphics, SymPy for symbolic math, NumPy and SciPy for numerical calculations, Pandas for data, and NLTK for natural language processing. Jupyter makes it easy to use Latex to display typeset math. With Matplotlib, Latex works even in the label text for graphs. (I have not yet tried the major update, JupyterLab, which is still in beta testing.) I’m more productive. I’m having fun. https://paulromer.net/jupyter-mathematica-and-the-future-of-the-research-paper/

Michael #3: Python Developers Survey 2017 Results

  • At the very end of 2017, JetBrains & The PSF teamed up to build a solid picture of the modern Python developer
  • Here are some take-aways
    • Almost 4 out of 5 Python developers use it as their main language, while for 21% it’s only a secondary language.
    • Data analysis is as popular as web development with Python: Web development is the only category with a large gap (54% vs 33%) separating those using Python as their main language vs as a supplementary language. For other types of development, the differences are far less significant.
    • At 28% to 27% application, There are as many Python web developers as Python data scientists
    • Python 3 vs Python 2: 75% to 25% and accelerating
    • Top Cloud Platform(s)
      • 67%: AWS
      • 29%: Google App Engine
      • 26%: Heroku
      • 23%: DigitalOcean
      • 16%: Microsoft Azure
    • Team Size
      • 74%: 2-7 people
      • 16%: 8-12 people
      • 5%: 13-20 people
      • 2%: 21-40 people
      • 2%: > 40 people
    • Operating Systems
      • 49%: Windows
      • 19%: Linux
      • 15%: MacOS

Brian #4: *EdgeDB: A New Beginning*
This is “news you can’t use” so far, because the product isn’t here yet. So why am I excited and interested in this:

  • It’s from Elvis @elprans and Yury @1st1, who have brought us asyncio and uvloop
  • It’s not just a relational DB, it’s a DB based on PostgreSQL but with an entire new way to specify schema and interact with it.
  • Goal is to be fast, user friendly, and remove the need for ORMs

Matt #5: Yellowbrick library

  • Visualization is important, I’ve found bugs by plotting before. Also important in evaluation of machine learning projects
  • This is a project that has been around for about two years. I’ve recently adopted it in place of some home grown libraries for some consulting projects and in my corporate training
  • Yellowbrick offers visualization for:
    • Features
    • Classification
    • Regression
    • Clustering
    • Text
  • Like sk-learn, uses a similar api (.fit, .transform, .poof (plot))

Michael #6: Depression AI

  • Alexa skill for people suffering with depression.
  • Alexa store listing
  • Based on Flask-Ask
  • Valley Hackathon 2018 winner
  • 71% of people who make their bed in the morning report feeling happy. This was the inspiration behind DepressionAI.
  • The aim behind this skill is to encourage people to perform daily activities that become very difficult when one is depressed.
  • The skill detects positive and negative moods.
  • If the user is having a bad day, it asks them a series of questions about what they have done that day (e.g. "Have you gotten out of bed?") and if they haven't, it encourages them to do so.
  • Features
    • Mood evaluation by a highly empathetic Alexa bot
    • Suicidal intention detection and prevention attempt
    • Location-based therapy reccomendations
    • Suggestions for small activites to improve the user's mood
    • Displays informative cards in the Alexa app
  • Sample Phrases
    • “Alexa, check on me."
    • "I feel down."
    • "I haven't got out of bed today."
    • "Help me feel better."
    • "Help me find a therapist"
Apr 19 2018
24 mins
Play

Rank #8: #45 A really small web API and OS-level machine learning

Podcast cover
Read more

This episode is brought to you by Rollbar: pythonbytes.fm/rollbar

Brian #1: pico

  • "a very small web application framework for Python"
  • Recommended by Ivan Pejić
  • lightning talk from EuroPython 2017
  • This would be a good web framework for building internal services and tools that non-web developers need to interact with and modify.
  • Very simple.
  • Not REST, but not confusing either.

Michael #2: High Sierra ships, first major OS with machine learning built in?

  • September 26th macOS High Sierra was released (yay)
  • Mostly a foundational release with barely visible changes but awesome things like APFS replacing HFS+, etc.
  • Comes with CoreML
    • Apple’s intent with the new CoreML framework is to package up prebuilt ML models and execution engines and make them possible for third-party apps to use.
    • Developers can take a trained machine learning algorithm, package it up as an MLModel, and integrate it into their apps.
    • Apple offers a few default machine learning models that developers can download and use too
  • Rather than sharing your data with a central server, grouping it together with a lot of other people's data, and improving machine learning models that way, Apple stresses that everything CoreML does is happening on the device.
  • On Macs that support Metal—generally, Macs from 2012 and later—CoreML uses a mix of CPU processing and GPGPU processing, depending on the task.
  • Add on the fact that High Sierra has external GPU support now and you have a sweet combo.

Brian #3: A guide to logging in Python

  • Simply put, the best logging introduction I've read so far.

Michael #4: Let me introduce: slots

  • So what are slots? __slots__ are a different way to define the attributes storage for classes in Python.
  • for normal Python classes, a dict is used to store the instance's attributes.
  • With __slots__ we don't have an attribute called __dict__ inside our instance. But we have a new attribute called __slots__.
  • But why would you need to use slots when you have a dict? Well the answer is that __slots__ are a lot lighter and slightly faster.
  • Outcome:
    • ~57% less memory usage thanks to just one line of code.
    • __slots__ are also slightly faster.
  • Covered in depth in my Write Pythonic Code Like a Seasoned Developer course.

Brian #5: pipenv revisited

  • Covered in episode 11. However, there are some notable changes since then.
  • Reminder:
    • pepenv handles virtualenv and pip interaction for you
    • pipenv install creates a virtualenv (if one doesn't exist) and installs stuff into a virtualenv.
    • pipenv shell uses the virtualenv
    • exit allows you to get out of the virtualenv
    • pipenv lock -r will generate a requirements.txt file for you, so you can use it even if you need a requirements.txt file.
  • Notable changes:
    • New 4 minute screencast with Kenneth demonstrating how to use it. Watching him use it makes it very simple to understand.
    • Specify multiple package indexes, and even specify a particular index for particular packages. So you can combine both pypi with a company index and a group index and maybe one for your project.
    • pipenv check will tell you about any known security vulnerabilities in your installed packages
    • 9 months old with 192 releases, so keep an eye on it for new features all the time.

Michael #6: Stack Overflow gives an even closer look at developer salaries

  • Tabs and spaces aren't the only things that influence developer pay…
  • Some of the broad trends are no big surprise; for example, the chosen cities tend to pay more than their respective nations do, for example.
  • DevOps specialists and data scientists both earn well.
  • Other aspects of the data are a little more surprising. Graphics programmers, for example, aren't particularly well paid, in spite of having a relatively specialized, complex niche.
  • And while earnings in four of the countries are surprisingly similar, those in America are substantially higher, regardless of experience; in fact, the median salary of a developer in the US is comparable to that of someone with 20 years of experience in Canada or Germany and markedly higher than 20-year veterans in France and the UK. Even after taking into account the US' higher healthcare costs, America is the place to be if you're a programmer.
  • Comments
    • I do have to wonder how much Silicon Valley skews that salary chart, as the Web 2.0 companies pay HUGE comparatively [ref]
    • I asked Stack Overflow's data scientist that question, and she said not much; even without its outlier cities, the US pays much more than the rest of the world. [ref]
    • Healthcare cost are only part of it. I got paid about $600/month 9 months a year by my government to study in university. [ref]
    • I feel like a lot of IT people lack soft skills, and it caps their salary at a lower end. [ref]

Our news:

Sep 29 2017
19 mins
Play

Rank #9: #95 Unleash the py-spy!

Podcast cover
Read more

Sponsored by DataDog -- pythonbytes.fm/datadog

Brian #1: dataset: databases for lazy people

  • dataset provides a simple abstraction layer removes most direct SQL statements without the necessity for a full ORM model - essentially, databases can be used like a JSON file or NoSQL store.
  • A simple data loading script using dataset might look like this:
import dataset

db = dataset.connect('sqlite:///:memory:')

table = db['sometable']
table.insert(dict(name='John Doe', age=37))
table.insert(dict(name='Jane Doe', age=34, gender='female'))

john = table.find_one(name='John Doe')

Michael #2: CuPy GPU NumPy

  • A NumPy-compatible matrix library accelerated by CUDA
  • How many cores does a modern GPU have?
  • CuPy's interface is highly compatible with NumPy; in most cases it can be used as a drop-in replacement.
  • You can easily make a custom CUDA kernel if you want to make your code run faster, requiring only a small code snippet of C++. CuPy automatically wraps and compiles it to make a CUDA binary
  • PyCon 2018 presentation: Shohei Hido - CuPy: A NumPy-compatible Library for GPU
  • Code example
>>> # This will run on your GPU!
>>> import cupy as np # This is the only non-NumPy line

>>> x = np.arange(6).reshape(2, 3).astype('f')
>>> x
array([[ 0., 1., 2.],
[ 3., 4., 5.]], dtype=float32)
>>> x.sum(axis=1)
array([ 3., 12.], dtype=float32)

Brian #3: Automate Python workflow using pre-commits

  • We covered pre-commit in episode 84, but I still had trouble getting my head around it.
  • This article by LJ Miranda does a great job with the workflow introduction and configuration necessary to get pre-commit working for black and flake8.
  • Includes a nice visual of the flow.
  • Demo of it all in action with a short video.

Michael #4: py-spy

  • Sampling profiler for Python programs
  • Written by Ben Frederickson
  • Lets you visualize what your Python program is spending time on without restarting the program or modifying the code in any way.
  • Written in Rust for speed
  • Doesn't run in the same process as the profiled Python program
  • Does NOT it interrupt the running program in any way.
  • This means Py-Spy is safe to use against production Python code.
  • The default visualization is a top-like live view of your python program
  • How does py-spy work? Py-spy works by directly reading the memory of the python program using the process_vm_readv system call on Linux, the vm_read call on OSX or the ReadProcessMemory call on Windows.

Brian #5: SymPy is a Python library for symbolic mathematics

  • “Symbolic computation deals with the computation of mathematical objects symbolically. This means that the mathematical objects are represented exactly, not approximately, and mathematical expressions with unevaluated variables are left in symbolic form.”
  • example:
>>> integrate(sin(x**2), (x, -oo, oo))
√2⋅√π
─────
2
  • examples on site are interactive so you can play with it without installing anything.

Michael #6: Starlette ASGI web framework

Extras:

Michael: PyCon 2019 dates out, put them on your calendar!

  • Tutorials: May 1-2 • Wednesday, Thursday
  • Talks and Events: May 3–5 • Friday, Saturday, Sunday
  • Sprints: May 6–9 • Monday through Thursday

Listener follow up on git pre-commit hooks util: pre-commit package

  • Matthew Layman, @mblayman
  • Heard the discussion about Git commit hooks at the end. I wanted to bring up pre-commit as an interesting project (written in Python!) that's useful for Git commit hooks.
  • tl;dr:
    • $ pip install pre-commit
    • $ ... create a .pre-commit-config.yaml
    • $ pre-commit install # This is a one time operation.
  • pre-commit's job is to manage a project's Git commit hooks. We use this on my team at work and the devs only need to run pre-commit install. This saves us from a bunch of failing CI builds where flake8 or other code style checks would fail.
  • We use pre-commit to run flake8 and black before allowing a commit to proceed. Some projects have a pre-commit configuration to use right out of the box (e.g., black https://github.com/ambv/black#version-control-integration).

Listener: You don't need that (pattern)

  • John Tocher
  • PyCon AU Talk Called "You don't need that” - by Christopher Neugebauer, it was an interesting take on why with a modern and powerful language like python, you may not need the conventionally described design patterns, ala the "Gang of four".
Sep 15 2018
23 mins
Play

Rank #10: #57 Our take on Excel and Python

Podcast cover
Read more

Sponsored by DigitalOcean: http://digitalocean.com

Brian #1: Testing Python 3 and 2 simultaneously with retox

  • Anthony Shaw
  • tox allows you to run the same tests in multiple configurations.
    • For example, multiple Python interpreters (2 vs 3), or on different hardware, or using different options, etc.
    • tox can also tests your packaging code (on by default, but can be disabled)
  • detox allows multiple configurations to be tested in parallel with multiprocessing
    • typically running all tests 2-4 times faster
  • retox does this with a GUI
    • also adds “watch” capability

Michael #2: Robo 3T / RoboMongo

  • MongoDB GUI with embedded shell
  • CLI interaction
  • GUI when you want it
  • No. 34 repository on GitHub

Brian #3: regular expressions

  • Regular Expressions Practical Guide
    • Python examples for some common expressions
    • How to use the built in re package for email addresses, URLs, phone numbers
    • substitution with re.sub()
    • splitting a string with re.split()
    • what some of the escape shortcuts mean, like \w for word, \s for whitespace, etc.
    • iterating through matches with re.finditer()
    • Using compiled expressions
  • Regular Expressions for Data Scientists
    • another great intro, that also talks about:
    • re.search()
    • re.findall()
    • match groups

Michael #4: MongoEngine

  • MongoEngine is a Document-Object Mapper (think ORM, but for document databases) for working with MongoDB from Python.
  • Map classes to MongoDB (think SQLAlchemy but for document databases)
  • Adds features lacking from MongoDB
    • Schema
    • Required fields
    • Constraints
    • Relationships

Brian #5: Introducing PrettyPrinter for Python

  • a powerful, syntax-highlighting, and declarative pretty printer for Python 3.6
  • goals
    • Implement an algorithm that tries very hard to produce pretty output, even if it takes a bit more work.
    • Implement a dead simple, declarative interface to writing your own pretty printers. Python developers rarely write __repr__ methods because they're a pain; no one will definitely write pretty printing rules for user-defined types unless it's super simple.
    • Implement syntax-highlighting that doesn't break on invalid Python syntax.

Michael #6: Excel and Python

  • Replace VBA
  • Python in Excel as the main scripting language
  • They need feedback (fill out their survey, upvote the issue)

Our news

Michael:

Dec 21 2017
15 mins
Play

Rank #11: #55 Flask, Flask, Flask, 3x Flask

Podcast cover
Read more

Sponsored by DigitalOcean: http://digitalocean.com

Brian #1 The Flask Mega-Tutorial, reborn

  • This very popular tutorial, written in 2012, has been rewritten.
  • Miguel Grinberg has rewritten it with the help of a kickstarter campaign.
  • Part 1 of the tutorial is up, and he’s releasing 1 part per week.
  • Want it faster, you can get it all in an eBook right now.
  • A video version is coming in January.

Michael #2: Django 2.0 Released

Brian #3: The Big Ol' List of Rules

  • Flake8 is a popular code linter that combines pyflakes, pycodestyle, and mccabe.
    • pycodestyle is the new pep8 to enforce PEP8 suggestions. These are mostly style guide items, and not actual bugs.
    • pyflakes is more like a traditional linter in that it catches things that are probably oversight or bugs.
    • mccabe is harder to explain, but it generally tells you if your code might be too complicated, using Cyclomatic Complexity.
  • Flake8 produces error codes if your code has problems
    • Ennn and Wnnn for pycodestyle errors and warnings
    • Fnnn for pyflakes errors
    • Cnnn for mccabe errors
  • The The Big Ol' List of Rules is a very nice breakdown of every error, what it means, and has links to other documents where they are defined.
  • Very nice work from Grant McConnaughey

Michael #4: requests-staticmock

  • via Anthony Shaw
  • The Session object allows you to persist certain parameters across requests. It also persists cookies across all requests made from the Session instance, and will use urllib3's connection pooling. So if you're making several requests to the same host, the underlying TCP connection will be reused, which can result in a significant performance increase
  • A Session object has all the methods of the main Requests API.
  • requests-staticmock is a static HTTP mock interface for testing classes that leverage Python requests with no monkey patching!

Brian #5: PEP 557 -- Data Classes have been approved

Very short Example lifted directly from PEP 557 doc.

@dataclass
class C:
a: int # 'a' has no default value
b: int = 0 # assign a default value for 'b'

In this example, both a and b will be included in the added __init__ method, which will be defined as:

def __init__(self, a: int, b: int = 0):
pass
  • Why not just use attrs? (Also lifted from the pep doc)
    • attrs moves faster than could be accommodated if it were moved in to the standard library.
    • attrs supports additional features not being proposed here: validators, converters, metadata, etc. Data Classes makes a tradeoff to achieve simplicity by not implementing these features.

Michael #6: Quart: 3x faster Flask

  • Python has evolved since Flask was first released around 8 years ago, particularly with the introduction of asyncio.
  • Asyncio has allowed for the development of libraries such as uvloop and asyncpg that are reported (here, and here) to improve performance far beyond what was previously possible.
  • Quart provides the easiest transition for Flask apps to use asyncio as it shares the Flask-API.
  • tl;dr: Upgrading this Flask-pyscopg2 app to a Quart-asyncpg app gives a performance speedup of 3x without requiring a major rewrite or adjustment of the code
  • View methods become async / await methods

Our news

Michael:

Dec 07 2017
20 mins
Play

Rank #12: #110 Python Year in Review 2018 Edition

Podcast cover
Read more

Sponsored by DigitalOcean: pythonbytes.fm/digitalocean

This episode originally aired on Talk Python at talkpython.fm/192.

It's been a fantastic year for Python. Literally, every year is better than the last with so much growth and excitement in the Python space. That's why I've asked two of my knowledgeable Python friends, Dan Bader and Brian Okken, to help pick the top 10 stories from the Python community for 2018.

Guests

10: Python 3.7:

9: Changes in versioning patterns

8: Python is becoming the world’s most popular coding language

7: 2018 was the year data science Pythonistas == web dev Pythonistas

6: Black

5: New PyPI launched!

4: Rise of Python in the embedded world

3: Legacy Python's days are fading?

2: It's the end of innocence for PyPi

1: Guido stepped down as BDFL

Dec 26 2018
56 mins
Play

Rank #13: #33 You should build an Alexa skill

Podcast cover
Read more

Sponsored by Rollbar! pythonbytes.fm/rollbar

Brian #1: Linting as Lightweight Defect Detection for Python

Michael #2: You should build an Alexa skill

  • Jacqueline Wilson wrote Amazon Alexa Skill Recipe with Python 3.6
  • Ingredients:
  • Create a “What’s for dinner” bot
  • Amazon calls these utterances:
    • “What should I have for dinner?”
    • “Do you have a dinner idea?”
    • “What’s for dinner?”
  • Tie the commands to an AWS Lambda function (returns a JSON response)
  • Test via Alexa Skill Testing Tool

Brian #3: RISE

  • Reveal IPython Slide Extension
  • Making slides with Jupyter notebooks

Michael #4: Closer

  • Run, monitor and close remote SSH processes automatically
  • Closer was born because I had trouble with killing up processes I set up remotely via SSH. That is, you want to run some SSH process in the background, and then you want to kill it, just like you would a local subprocess.
  • Main features:
    • kill the remote process (either by choice, or automatically at the end of the calling process)
    • capture the remote process’s output
    • live monitoring of remote process output
    • get a callback upon remote process’ death

Brian #5: Checklist for *Python libraries APIs*

Michael #6: Fades

  • Fades is a system that automatically handles the virtualenvs in the cases normally found when writing scripts and simple programs, and even helps to administer big projects.
  • fades will automagically create a new virtualenv (or reuse a previous created one), installing the necessary dependencies, and execute your script inside that virtualenv, with the only requirement of executing the script with fades and also marking the required dependencies.
  • At the moment you execute the script, fades will search a virtualenv with the marked dependencies, if it doesn’t exists fades will create it, and execute the script in that environment.
  • Indicating dependencies (in code or via CLI)
import somemodule # fades == 3
import somemodule # fades >= 2.1
import somemodule # fades >=2.1,<2.8,!=2.6.5
  • Can control the Python version the env is based upon
  • Can ask for a “refresh” on the virtual env
  • You can also configure fades using .ini config files.
  • How to clean up old virtualenvs?

Listener comment, RE: Episode 32:

Jan Oglop:

Hello Michael and Brian, I wanted to thank you for amazing work you do. And let you know that you have helped me to find the working place from my dreams! My colleagues has similar hobbies and loves python as much as I do!

Thank you again!

Jul 06 2017
17 mins
Play

Rank #14: #140 Becoming a 10x Developer (sorta)

Podcast cover
Read more

Sponsored by DigitalOcean: pythonbytes.fm/digitalocean

Brian #1: Becoming a 10x Developer : 10 ways to be a better teammate

  • Kate Heddleston
  • “A 10x engineer isn’t someone who is 10x better than those around them, but someone who makes those around them 10x better.”
    1. Create an environment of psychological safety
    2. Encourage everyone to participate equally
    3. Assign credit accurately and generously
    4. Amplify unheard voices in meetings
    5. Give constructive, actionable feedback and avoid personal criticism
    6. Hold yourself and others accountable
    7. Cultivate excellence in an area that is valuable to the team
    8. Educate yourself about diversity, inclusivity, and equality in the workplace
    9. Maintain a growth mindset
    10. Advocate for company policies that increase workplace equality
  • article includes lots of actionable advice on how to put these into practice.
  • examples:
    • Ask people their opinions in meetings.
    • Notice when someone else might be dominating a conversation and make room for others to speak.

Michael #2: quasar & vue.py

  • via Doug Farrell
  • Quasar is a Vue.js based framework, which allows you as a web developer to quickly create responsive++ websites/apps in many flavours:
    • SPAs (Single Page App)
    • SSR (Server-side Rendered App) (+ optional PWA client takeover)
    • PWAs (Progressive Web App)
    • Mobile Apps (Android, iOS, …) through Apache Cordova
    • Multi-platform Desktop Apps (using Electron)
  • Great for python backends
  • tons of vue components
  • But could it be all python?
    • vue.py provides Python bindings for Vue.js. It uses brython to run Python in the browser.
    • Examples can be found here.

Brian #3: Regular Expressions 101

  • We talked about regular expressions in episode 138
  • Some tools shared with me after I shared a regex joke on twitter, including this one.
  • build expressions for Python and also PHP, JavaScript, and Go
  • put in an example, and build the regex to match
  • explanations included
  • match information including match groups and multiple matches
  • quick reference of all the special characters and what they mean
  • generates code for you to see how to use it in Python
  • Also fun (and shared from twitter):
    • Regex Golf
      • see how far you can get matching strings on the left but not the list on the right.
        • I got 3 in and got stuck. seems I need to practice some more

Michael #4: python-diskcache

  • Caching can be HUGE for perf benefits
  • But memory can be an issue
  • Persistence across executions (e.g. web app redeploy) an issue
  • Servers can be issues themselves
  • Enter the disk! Python disk-backed cache (Django-compatible). Faster than Redis and Memcached. Pure-Python.
  • DigitalOcean and many hosts now offer SSD’s be default
  • Unfortunately the file-based cache in Django is essentially broken.
  • DiskCache efficiently makes gigabytes of storage space available for caching.
    • By leveraging rock-solid database libraries and memory-mapped files, cache performance can match and exceed industry-standard solutions.
    • There's no need for a C compiler or running another process.
    • Performance is a feature
    • Testing has 100% coverage with unit tests and hours of stress.
  • Nice comparison chart

Brian #5: The Python Help System

  • Overview of the built in Python help system, help()
  • examples to try in a repl
    • help(print)
    • help(dict)
    • help('assert')
    • import math; help(math.log)
  • Also returns docstrings from your non-built-in stuff, like your own methods.

Michael #6: Python Architecture Graphs

  • by David Seddon
  • Impulse - a CLI which allows you to quickly see a picture of the import graph any installed Python package at any level within the package.
  • Useful to run on an unfamiliar part of a code base, to help get a quick idea of the structure.
  • It's a visual explorer to give you a quick signal on architecture.
  • Import Linter - this allows you to declare and check contracts about your dependency graph, which gives you the ability to lint your code base against architectural rules.
  • Helpful to enforce certain architectural constraints and prevent circular dependencies creeping in.

Extras

Michael:

Jokes

Two threads walk into a bar. The barkeeper looks up and yells, 'Hey, I want don't any conditions race like time last!’

A string value walked into a bar, and then was sent to stdout.

Jul 23 2019
24 mins
Play

Rank #15: #91 Will there be a PyBlazor?

Podcast cover
Read more

Sponsored by Datadog pythonbytes.fm/datadog

Brian #1: What makes the Python Cool

  • Shankar Jha
  • “some of the cool feature provided by Python”
  • The Zen of Python: import this
  • XKCD: import antigravity
  • Swapping of two variable in one line: a, b = b, a
  • Create a web server using one line: python -m http.server 8000
  • collections
  • itertools
  • Looping with index: enumerate
  • reverse a list: list(reversed(a_list))
  • zip tricks
  • list/set/dict comprehensions
  • Modern dictionary
  • pprint
  • _ when in interactive REPL
  • Lots of great external libraries

Michael #2: Django 2.1 released

Brian #3: Awesome Python Features Explained Using Harry Potter

  • Anna-Lena Popkes
  • Initial blog post
  • 100 Days of code, with a Harry Potter universe bent.
  • Up to day 18 so far.

Michael #4: Executing Encrypted Python with no Performance Penalty

  • Deploying Python in production presents a large attack surface that allows a malicious user to modify or reverse engineer potentially sensitive business logic.
  • This is worse in cases of distributed apps.
  • Common techniques to protect code in production are binary signing, obfuscation, or encryption. But, these techniques typically assume that we are protecting either a single file (EXE), or a small set of files (EXE and DLLs).
  • In Python signing is not an option and source code is wide open.
  • requirements were threefold:
    1. Work with the reference implementation of Python,
    2. Provide strong protection of code against malicious and natural threats,
    3. Be performant both in execution time and in stored space
  • This led to a pure Python solution using authenticated cryptography.
  • Created a .pyce file that is encrypted and signed
  • Customized import statement to load and decrypt them
  • Implementation has no overhead in production. This is due to Python's in-memory bytecode cache.

Brian #5: icdiff and pytest-icdiff

  • icdiff: “Improved colored diff”
    • Jeff Kaufman
  • pytest-icdiff: “better error messages for assert equals in pytest”
    • Harry Percival

Michael #6: Will there be a PyBlazor?

  • The .NET guys, and Steve Sanderson in particular, are undertaking an interesting project with WebAssembly.
  • WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable target for compilation of high-level languages like C/C++/Rust, enabling deployment on the web for client and server applications.
  • Works in Firefox, Edge, Safari, and Chrome
  • Their project, Blazor, has nearly the entire .NET runtime (AKA the CLR) running natively in the browser via WebAssembly.
  • This is notable because the CLR is basically pure C code. What else is C code? Well, CPython!
  • Includes Interpreted and AOT mode:
    • Ahead-of-time (AOT) compiled mode: In AOT mode, your application’s .NET assemblies are transformed to pure WebAssembly binaries at build time.
  • Being able to run .NET in the browser is a good start, but it’s not enough. To be a productive app builder, you’ll need a coherent set of standard solutions to standard problems such as UI composition/reuse, state management, routing, unit testing, build optimization, and much more.
  • Mozilla called for this to exist for Python, but sadly didn’t contribute or kick anything off at PyCon 2018: https://www.youtube.com/watch?v=ITksU31c1WY
  • Gary Bernhardt’s Birth and Death of JavaScript video is required pre-reqs as well (asm.js).

Extras and personal info:

Michael:

Aug 15 2018
20 mins
Play

Rank #16: #30 You are not Google and other ruminations

Podcast cover
Read more

Python Bytes 30

Sponsored by Datadog: Try Datadog and get a free shirt at pythonbytes.fm/datadog.

Brian #1: Problems and Solutions are different at different scales

Michael #2: Introducing NoDB - a Pythonic Object Store for S3

  • Released in April 2017 by Rich Jones
  • An incredibly simple, Pythonic object store based on Amazon's S3 static file storage.
  • NoDB isn't a database.. but it sort of looks like one!
  • Kind of like a document database, supports indexing
  • Can use Pickling or JSON
  • Mostly useful for prototyping, casual hacking, and (maybe) even low-traffic server-less databases for Zappa apps!
  • Can see a few use cases for NoDB:
    • Prototyping schemas
    • Storing API event responses for later replay
    • Capturing event logs
    • Storing simple form data (email addresses, etc.)
    • Storing non-relational analytics data
    • Firing Lambda event triggers
    • Version controlling evolving Python objects
    • Storing and loading trained machine learning models
  • https://github.com/Miserlou/NoDB

Brian #3: Elizabeth for mock data
Part 1: https://medium.com/wemake-services/generating-mock-data-using-elizabeth-part-i-ca5a55b8027c
Part 2: https://medium.com/wemake-services/generating-mock-data-with-elizabeth-part-ii-bb16a3f3106f
pytest plugin: https://github.com/lk-geimfari/pytest-elizabeth

Michael #4: What’s New In Python 3.7

  • Lang: More than 255 arguments can now be passed to a function, and a function can now have more than 255 parameters.
  • Lang: bytes.fromhex() and bytearray.fromhex() now ignore all ASCII whitespace, not only spaces.
  • Lang: Circular imports involving absolute imports with binding a submodule to a name are now supported.
  • Module: contextlib.asynccontextmanager() has been added.
    • Similar to contextmanager(), but creates an asynchronous context manager.
    • This function is a decorator that can be used to define a factory function for async with statement asynchronous context managers, without needing to create a class or separate __aenter__() and __aexit__() methods.
  • Module:The dis() function now is able to disassemble nested code objects (the code of comprehensions, generator expressions and nested functions, and the code used for building nested classes).
  • Module: math: New remainder() function, implementing the IEEE 754-style remainder operation.
  • Optimization: Added two new opcodes: LOAD_METHOD and CALL_METHOD to avoid instantiation of bound method objects for method calls, which results in method calls being faster up to 20%.
  • Optimization: The os.fwalk() function has been sped up by 2 times.

Brian #5: Hypothesis Testing

Michael #6: Heroku switching default to v3.6.1

  • Effective Tuesday, June 20th, 2017, new Python applications pushed to Heroku will use the python-3.6.1 runtime by default (instead of python-2.7.13).
  • Existing applications will not be affected by this change.
  • “Lots of new projects start out on heroku all the time, so this is really great news for python 3 adoption.”
  • “Python 3 is really happening. I was actually a little worried about the future of Python for a while.”
Jun 15 2017
24 mins
Play

Rank #17: #60 Don't dismiss SQLite as just a starter DB

Podcast cover
Read more

Brought to you by Datadog pythonbytes.fm/datadog

Brian #1: Who's at nine?

Michael #2: Retiring Python as a teaching language

  • Why did he write this?
    • Then one day a student will innocently ask "Instead of running the poker simulator from the command line, how can I put it in a window with a button to deal the next hand?"
  • The ensuing Twitter conversation was very interesting. Scroll this status, it’s pretty comprehensive https://twitter.com/mkennedy/status/949688651058835456

Brian #3: Don't dismiss SQLite as just a starter DB

  • SQLite is a single file db that comes with Python.
  • A listener pointed us to a couple cool things about SQLite
  • A great interview with the developer The Changelog, episode 201.
  • It's extensive documentation on how SQLite is tested.
  • Of course, for web applications and other applications that have to deal with extreme concurrency, you need a client server database
  • Many applications don't have extreme concurrency needs.
  • Sticking with SQLite might be just fine for quite a long time for many apps.

Michael #4: Chalice: Python Serverless Microframework for AWS

  • Chalice is a python serverless microframework for AWS. It allows you to quickly create and deploy applications that use Amazon API Gateway and AWS Lambda.
  • It provides:
    • A command line tool for creating, deploying, and managing your app
    • A familiar and easy to use API for declaring views in python code (Flask)
    • Automatic IAM policy generation
  • Compare to Zappa: https://github.com/Miserlou/Zappa

Brian #5: Fastest way to uniquely a list in Python >=3.6

  • Nice analysis of different ways to uniquify a list.
  • Punchline:
    • The fastest way to uniqify a list of hashable objects (basically immutable things) is: list(set(seq))
    • And the fastest way, if the order is important is: list(dict.fromkeys(seq))

Michael #6: PyTexas and PyCon AU vidoes are up

  • PyTexas
    • Notable PyTexas videos
      • Micropython
      • What is ML?
      • C for yourself
      • Python and .NET
  • PyCon AU
    • Notable PyCon AU videos
      • Gradual typing
      • Hot reloading Python web-servers at scale
      • Prototyping Python Microservices in Production
      • Secrets of a WSGI master.
      • Python 3 for People Who Haven't Been Paying Attention
      • Identity 2.0: the what, why and how of social and federated login
      • Python: Ludicrous mode (with Django)
      • Scaling Down: Running Large Sites Locally

Our news

Michael

Mastering PyCharm is out. Includes

  • Learn to manage Python projects in PyCharm (large and small)
  • Create web applications (Pyramid, Flask, Django, and more)
  • Use PyCharm's special data science mode
  • Refactor your Python code with confidence
  • Learn about code smells and duplicate code tooling
  • Access git, github, and use git flow
  • Use the visual debugger to understand code flow and state
  • Make your code more reliable with unit testing and pytest
  • Create new Python packages
  • And lots more

Webcast with JetBrains: MongoDB Quickstart with Python and PyCharm Jan 30

Jan 11 2018
26 mins
Play

Rank #18: #52 Call your APIs with uplink and test them in the tavern

Podcast cover
Read more

Sponsored by DigitalOcean. They just launched Spaces, get started today with a free 2 month trial of Spaces by going to do.co/python

Brian #1: Restful API testing with Tavern

Michael #2: Uplink

  • RESTful client API via decorators
  • Create a class to represent the API
  • Add methods with arguments, map to API calls.
  • e.g.
@get("/users/{username}")
def get_user(self, username):
"""Get a single user."""
  • Uplink includes support for concurrent requests with asyncio (for Python 3.4+)
  • Twisted (for all supported Python versions)
  • Not production ready, but very exciting.

Brian #3: Using json-schema for REST API endpoint tests

Sponsor DIGITAL OCEAN SPACES
Get started today with a free 2 month trial of Spaces by going to do.co/python

Michael #4: Live coding to music!

  • via Ian Watt
  • Talk at PyCon UK by Ryan Kirkbride called “Programming Music for Performance: Live coding with FoxDot”

Brian #5: Weekly Python Chat

Michael #6: 10 common beginner mistakes in Python

  1. Incorrect indentation, tabs and spaces
  2. Using a Mutable Value as a Default Value
  3. Write a lot of comments and docstrings
  4. Scoping
  5. Edge cases first (let’s go easy on the indents)
  6. Copying
  7. Creating count-by-one errors on loops (range is half closed)
  8. Wrong capitalization
  9. Using class variables incorrectly

Our news

Michael:

  • Flash briefing?
  • Firefox Quantum!
Nov 16 2017
21 mins
Play

Rank #19: #77 You Don't Have To Be a Workaholic To Win

Podcast cover
Read more

Sponsored by Datadog: pythonbytes.fm/datadog

Brian #1: Why Senior Devs Write Dumb Code

  • Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” - Kent Beck
  • Code that is clean, straightforward, obvious, and easy to read actually takes practice to achieve.
  • Follow principles like YAGNI, Singe Responsibility, DRY, etc.
  • Avoid clever one-liners, weird abstractions.
  • Esoteric language features.
  • Code needs to be readable and easily understood while under time and stress pressure.

Michael #2: GeoAlchemy 2

  • GeoAlchemy 2 provides extensions to SQLAlchemy for working with spatial databases.
  • GeoAlchemy 2 focuses on PostGIS. Aims to be simpler than its predecessor, GeoAlchemy.
  • Using it:
    • Connect (e.g. Postgres)
    • Declare a Mapping
class Lake(Base):
__tablename__ = 'lake'
id = Column(Integer, primary_key=True)
name = Column(String)
geom = Column(Geometry('POLYGON'))
  • Create a table (via the engine)
  • Create an Instance of the Mapped Class
  • Inserts like standard SQLAlchmey
  • Spatial Query
from sqlalchemy import func
query = session.query(Lake).filter(
func.ST_Contains(Lake.geom, 'POINT(4 1)'))

query = session.query(Lake.name,
Lake.geom.ST_Buffer(2).ST_Area().label('bufferarea'))

Brian #3: QtPyConvert

  • An automatic Python Qt binding transpiler to the Qt.py abstraction layer.
  • QtPyConvert supports the following bindings out of the box:
  • Conversions leave code comments in place, with the help of RedBaron
  • Converts to Qt.py
    • Minimal Python 2 & 3 shim around all Qt bindings - PySide, PySide2, PyQt4 and PyQt5

Michael #4: You Don't Have To Be a Workaholic To Win: 13 Alternative Ways To Stand Out

  • Do we have to kill ourselves to get ahead?
  • Don’t busy-brag
  • Max Q analogy
  • The tips
  • Creativity
  • Stubbornness
  • Curiosity
  • Kindness
  • Planning
  • Improvisation
  • Enthusiasm
  • Communication
  • Presence
  • Collaboration
  • Willingness
  • Patience
  • Institutional Knowledge

Brian #5: RedBaron

  • RedBaron is a python library to make the process of writing code that modify source code as easy and as simple as possible.
    • writing custom refactoring, generic refactoring, tools,
  • Used by QtPyConvert to achieve the conversion while leaving code comments in place
  • Uses the full syntax tree, FST. Like an AST, but keeps all information, including comments and formatting.
  • possible uses:
    • rename a variable in a source file... without clashing with things that are not a variable (example: stuff inside a string)
    • inline a function/method
    • extract a function/method from a series of line of code
    • split a class into several classes
    • split a file into several modules
    • convert your whole code base from one ORM to another
    • do custom refactoring operation not implemented by IDE

Michael #6: Project Beeware AppStore

  • Project BeeWare has just released its first iPhone app made in Python using its Briefcase tool.
  • Simple travel app for currency and tip calculations
  • Briefcase: A distutils extension to assist in packaging Python projects as standalone applications.
    Briefcase is a tool for converting a Python project into a standalone native application. You can package projects for:
    • Mac
    • Windows
    • Linux
    • iPhone/iPad
    • Android
    • AppleTV
    • tvOS
  • While there are other Python GUI toolkits aiming to enable Python developers to build and deploy iOS apps, like for instance the very nice Pythonista app, the BeeWare project is a bit different because it aims at cross-platform compatibility and native widgets with a set of different tools, like Briefcase and Toga.

Extras:

May 12 2018
21 mins
Play

Rank #20: #87 Guido van Rossum steps down

Podcast cover
Read more

Sponsored by Datadog: pythonbytes.fm/datadog

Special guests:

The topic: Guido steps down.

The announcement: Transfer of Power

Now that PEP 572 is done, I don't ever want to have to fight so hard for a PEP and find that so many people despise my decisions.

I would like to remove myself entirely from the decision process. I'll still be there for a while as an ordinary core dev, and I'll still be available to mentor people -- possibly more available. But I'm basically giving myself a permanent vacation from being BDFL, and you all will be on your own.

After all that's eventually going to happen regardless -- there's still that bus lurking around the corner, and I'm not getting younger... (I'll spare you the list of medical issues.)

I am not going to appoint a successor.

So what are you all going to do? Create a democracy? Anarchy? A dictatorship? A federation?

I'm not worried about the day to day decisions in the issue tracker or on GitHub. Very rarely I get asked for an opinion, and usually it's not actually important. So this can just be dealt with as it has always been.

The decisions that most matter are probably - How are PEPs decided - How are new core devs inducted

We may be able to write up processes for these things as PEPs (maybe those PEPs will form a kind of constitution). But here's the catch. I'm going to try and let you all (the current committers) figure it out for yourselves.

Note that there's still the CoC -- if you don't like that document your only option might be to leave this group voluntarily. Perhaps there are issues to decide like when should someone be kicked out (this could be banning people from python-dev or python-ideas too, since those are also covered by the CoC).

Finally. A reminder that the archives of this list are public ( https://mail.python.org/pipermail/python-committers/ ) although membership is closed (limited to core devs).

I'll still be here, but I'm trying to let you all figure something out for yourselves. I'm tired, and need a very long break.

--Guido van Rossum (python.org/~guido)

Why it happened?

What this means?

  • “keep calm and keep coding”

Is there a danger of Python losing its momentum from this?

What comes next?

  • current state of the governance discussion

What needs to be done to reduce this kind of pressure?

Brett’s talk about setting open source expectations at PyCascades is very relevant.

Jul 17 2018
33 mins
Play

Similar Podcasts