#188 Will there be a "switch" in Python the language?

Python Bytes - Podcast tekijän mukaan Michael Kennedy and Brian Okken - Maanantaisin

Kategoriat:

Sponsored by us! Support our work through:

Michael #1: Making a trading bot asynchronous using Python’s “unsync” library

  • by Matt Gosden
  • The older way — using the threading and multiprocessing libraries
  • The newer way — using async and await from the asyncio library embedded into core Python from 3.7 onwards
  • The easier way (I think)— using the @unsync decorator from the Python unsync library
  • Somewhat realistic example worth looking at.
  • Could discuss scalability more
  • Also, proper def async and asyncio.sleep() for those playing at home
  • But its absence kind shows unsync winning anyway. 🙂 It does work, right?

Brian #2: *Fruit salad scrum estimation scale*

  • From twitter question by Lacy Henschel, answered by Kathleen Jones
  • Fruit related to work
    • how easy
    • potential for mess
    • how many seeds, possible problems
    • does it need divided
  • The scale
    • 1 - grape - trivial
    • 2 - apple - may take a bit of time but everyone knows how to divide it
    • 3 - cherry - easy but with some unknowns (what do you do with the pit?)
    • 5 - pineapple - somewhat undefined, no major unknowns, still a lot of work (lots of opinions on how to cut it)
    • 8 - watermelon - lots of work, some unknowns, messy (don’t know what you are getting into until you cut it open)
    • ?? - tomato - unknown task, needs more info before estimating (doesn’t belong in a fruit salad)
    • ?? - avacado - not scopable, probably urgent (goes bad quickly)

Michael #3: Math to Code

  • Math to Code is an interactive Python tutorial to teach engineers how to read and implement math using the NumPy library.
  • by vernon thommeret
  • Nice flashcard style of learning the building blocks of np for standard math
  • Give it a try, solutions if you get stuck
  • Python and NP together
  • Source at github
  • Interesting building blocks
  • Skulpt for interpreting Python
  • Skulpt NumPy for a subset of NumPy
  • KaTex for rendering LaTeX
  • Next.js for frontend framework
  • Tailwind CSS for styling
  • remark for rendering Markdown questions
  • gray-matter for extracting Markdown frontmatter
  • RealFavIconGenerator for generating favicons

Brian #4: PEP 622 -- Structural Pattern Matching

  • Draft status, targeted for Python 3.10
  • Syntax looks similar to switch/case statement, even though two switch PEPs were rejected earlier
  • Designed not only to optimize if/elif/else statements but also to focus on sequence, mapping, and object destructuring.
  • match/case statement with many allowed patterns:
    • literal pattern: would then act similar to a switch/case statement
    • name pattern: assigns expression to new variable if previous case doesn’t succeed
    • constant value pattern: enums, similar to literal
    • sequence pattern: works like unpacking assignment
    • mapping pattern: like sequence unpacking, but for mappings, like dictionaries
    • class pattern: create objects for each case and call __match__()
    • combining patterns: | for multiple patterns. including binding patterns like name
    • guards: if expression to further clarify a case
    • named sub-patterns: ok. still getting my head around this

Michael #5: CodeArtifact from AWS

  • via Tormod Macleod
  • AWS CodeArtifact is a fully managed software artifact repository service that makes it easy for organizations of any size to securely store, publish, and share packages used in their software development process
  • AWS CodeArtifact works with commonly used package managers and build tools such as Maven and Gradle (Java), npm and yarn (JavaScript), pip and twine (Python), making it easy to integrate CodeArtifact into your existing development workflows.
  • Can be configured to automatically fetch software packages from public artifact repositories such as npm public registry, Maven Central, and Python Package Index (PyPI), ensuring teams have reliable access to the most up-to-date packages.

Brian #6: invoke

  • suggested by Joreg Benesch
  • replacement for Makefiles
  • Confusion:
    • documentation is at pyinvoke.org
    • install with pip install invoke
    • there’s also another pypi package, called pyinvoke, which is NOT what we are talking about.
  • invoke:
    • task execution library
    • Write tasks.py files in Python for Makefile like things
    • tasks are Python functions decorated with @task, like

`` @task def build(c, clean=False): if clean: print("Cleaning!") print("Building!") - invoke tasks withinvoke $ invoke build -c $ invoke build --clean - you can - run shell commands withc.run()` - declare pre-tasks, tasks that need to run before this one. like “build” requires “clean”, etc. - namespaces with multiple files - tool intended for building documentation, but could probably run lots of stuff with it, like deployment, testing, etc.

Extras:

Brian:

  • Michael:

  • From Guido: Python 3.9.0 beta 3 is out now, for your immediate testing. Wait, what happened to beta 2? Interesting story.

  • The next pre-release, the fourth beta release of Python 3.9, will be 3.9.0b4. It is currently scheduled for 2020-06-29.

Joke:

Visit the podcast's native language site