|
Description:
|
|
Watch on YouTube
About the show
Python Bytes 311
Sponsored by Microsoft for Startups Founders Hub.
Connect with the hosts
Michael #1: Latexify
Brian #2: prefixed
- From Avram Lubkin
“Prefixed provides an alternative implementation of the built-in float which supports formatted output with SI (decimal) and IEC (binary) prefixes.”
>>> from prefixed import Float
>>> f'{Float(3250):.2h}'
'3.25k'
>>> '{:.2h}s'.format(Float(.00001534))
'15.34μs'
>>> '{:.2k}B'.format(Float(42467328))
'40.50MiB'
>>> f'{Float(2048):.2m}B'
'2.00KB'
Because prefixed.Float inherits from the built-in float, it behaves exactly the same in most cases.
- When a math operation is performed with another real number type (float, int), the result will be a prefixed.Float instance.
- also interesting
-
Murilo #3: dbt
- Open source tool
- CLI tool
- Built with Python
- Applies “best practices” to SQL projects
- Combines git +
.sql files + jinja
- Support many data platforms
- Let’s you
- Template SQL queries
- Execute DAGs
- Data validation
- Easily build docs (data lineage, visualize DAGs, etc.)
- Now you can also run Python models
- Useful if there’s a convenient python function for your data transformation or some more complex logic (i.e.:fuzzy string matching, machine learning models, etc.)
- Available for Snowflake, Databricks, BigQuery
- dbt’s coalesce’s announcement https://www.youtube.com/watch?v=rVprdyxcGUo
Michael #4: Memray pytest plugin
Brian #5: Stealing Open Source code from Textual
- Will McGugan
- Will reminds us of one of the great benefits of open source code, stealing code
- (when allowed by the license, of course)
- Goes as far as to point out some bits of textual that you might want to lift
- looping with indication of when you’ve hit the first or last item
- a LRUCache with more flexibility than lru_cache
- a Color class with conversions for css, hex, monochrome, hsl
- 2d geometry
Murilo #6: Shed
- Superset of black
- "
shed is the maximally opinionated autoformatting tool. It's all about convention over configuration, and designed to be a single opinionated tool that fully canonicalises my code - formatting, imports, updates, and every other fix I can possibly automate.”
- Also format code snippets in docstrings, markdown, restructured text
- No configuration options
- pre-commit hooks available
- Bundles together:
black
isort
autoflake
pyupgrade
blacken-docs
Extras
Brian:
- pytest-check (version 1.1.3) changes now live
- New README, hopefully makes it clear how to use.
- Use
check from
from pytest_check import check
- or from the
check fixture: def test_foo(check): …
- Either form returns the same object.
- From that
check object, you can
- use helper functions like
check.equal(a, b), etc.
- use it as a context manager,
with check: assert a == b
- even grab the
raises context manager: with check.raises(Exception): …
- Intended to be backwards compatible
- although some old use cases might be deprecated/removed in the future.
Michael:
Murilo:
Joke:
|