Brought to you by Michael and Brian - take a Talk Python course or get Brian's pytest book

#154: Code, frozen in carbon, on display for all

Published Tue, Oct 29, 2019, recorded Wed, Oct 23, 2019

Sponsored by Datadog: pythonbytes.fm/datadog

Special guest: Bob Belderbos

Brian #1: Lesser Known Coding Fonts

  • Interesting examination of some coding fonts.
  • Link to a great talk called Cracking the Code, by Jonathan David Ross, about coding fonts and Input.

I’m trying out Input Mono right now, and quite like it.

Bob #2: Django Admin Handbook

Michael #3: Your Guide to the CPython Source Code

  • Let’s talk about exploring the CPython code
  • You’ll want to get the code: git clone https://github.com/python/cpython
  • Compile the code (Anthony gives lots of steps for macOS, Windows, and Linux)
  • Structure:

        cpython/
        │
        ├── Doc      ← Source for the documentation
        ├── Grammar  ← The computer-readable language definition
        ├── Include  ← The C header files
        ├── Lib      ← Standard library modules written in Python
        ├── Mac      ← macOS support files
        ├── Misc     ← Miscellaneous files
        ├── Modules  ← Standard Library Modules written in C
        ├── Objects  ← Core types and the object model
        ├── Parser   ← The Python parser source code
        ├── PC       ← Windows build support files
        ├── PCbuild  ← Windows build support files for older Windows versions
        ├── Programs ← Source code for the python executable and other binaries
        ├── Python   ← The CPython interpreter source code
        └── Tools    ← Standalone tools useful for building or extending Python
    
  • Some cool “hidden” goodies. For example, check out Lib/concurrent/futures/process.py, it comes with a cool ascii diagram of the process.

  • Lots more covered, that we don’t have time for
    • The Python Interpreter Process
    • The CPython Compiler and Execution Loop
    • Objects in CPython
    • The CPython Standard Library
    • Installing a custom version

Brian #4: Six Django template tags not often used in tutorials

  • Here’s a few:
    • {% empty %}, for use in for loops when the array is empty
    • {% lorem \[count\] [method] [random] %} for automatically filling with Lorem Ipsum text.
    • {% verbatim %} … {% endverbatim %}, stop the rendering engine from trying to parse it and replace stuff.
    • https://hipsum.co/

Bob #5: Beautiful code snippets with Carbon

  • Beautiful images, great for teaching Python / programming.
  • Used by a lot of developer, nice example I spotted today.
  • Supports typing and drag and drop, just generated this link by dropping a test module onto the canvas!
  • Great to expand Twitter char limit (we use it to generate Python Tip images).
  • Follow the project here, seems they now integrate with Github.

Michael #6: Researchers find bug in Python script may have affected hundreds of studies

  • More info via Mike Driscoll at Thousands of Scientific Papers May be Invalid Due to Misunderstanding Python
  • In a paper published October 8, researchers at the University of Hawaii found that a programming error in a set of Python scripts commonly used for computational analysis of chemistry data returned varying results based on which operating system they were run on.
  • Scientists did not understand that Python’s glob.glob() does not return sorted results
  • Throwing doubt on the results of more than 150 published chemistry studies.
  • the researcher were trying to analyze results from an experiment involving cyanobacteria discovered significant variations in results run against the same nuclear magnetic resonance spectroscopy (NMR) data.
  • The scripts, called the "Willoughby-Hoye" scripts after their creators, were found to return correct results on macOS Mavericks and Windows 10. But on macOS Mojave and Ubuntu, the results were off by nearly a full percent.
  • The module depends on the operating system for the order in which the files are returned. And the results of the scripts' calculations are affected by the order in which the files are processed.
  • The fix: A simple list.sort()!
  • Williams said he hopes the paper will get scientists to pay more attention to the computational side of experiments in the future.

Extras:

Working on: PyBites platform: added flake8/ black code formatting, UI enhancements.

Michael:

Joke:

  • Q: What did the Network Administrator say when they caught a nasty virus?
  • A: It hurts when IP

Want to go deeper? Check our projects