Watch the live stream: Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Michael #1: Human regular expressions revisited via Mikael Honkala We mentioned of Al Sweigart's humre in Python Bytes… Mikael went on a little search and compiled my findings into this repo. A lot of people feel that re needs some help. At least 3 of the "serious" packages I found came out in the last few months. Since a package like this is not overly complex to make, all the ways to approach the problem are clearly being explored. Unfortunately these seem to be mostly single-person efforts, and many have fallen to the wayside before long. Hopefully there's some consolidation on the horizon, to share some of the maintenance effort and establish some of the packages as here for the long haul. The list could be useful to you if you are: Looking for a tool: Check the list to get a quick idea of the "look and feel" of each package. Thinking about building a tool: Check the list for alternative approaches, and maybe consider if contributing to an existing package might be a better way to get what you need. Building a tool, or already have one: Use the list to clarify and communicate what the main differences and strengths of your solution are. Brian #2: Implicit Optional Types Will Be Disabled by Default … in a future mypy feature release (possibly the next one after 0.98x) … Thanks Adam Johnson for spotting this and letting us know Stop doing this: s: str = None Do one of these: s: str | None = None s: Union[str, None] = None s: Optional[str] = None ← but this has problems Optional != optional From python docs: ”Optional[X] is equivalent to X | None (or Union[X, None]).” “Note that this is not the same concept as an optional argument, which is one that has a default. An optional argument with a default does not require the Optional qualifier on its type annotation just because it is optional. “ Best described in FastAPI docs, Python Types Intro, starting at “Possibly None" Recommendation is to use: s: str | None = None for Python 3.10+ s: Union[str, None] = None for Python 3.9+ For 3.7, 3.8, you still have Optional as an option, I think. Why haven't you upgraded to 3.9? We're almost to 3.11, what's the problem?! Michael #3: cython-lint by Marco Gorelli A tool (and pre-commit hook) to lint Cython files, similar to how flake8 lints Python files, and works by parsing Cython's own AST (abstract syntax tree). Found quite a few nice clean-ups which could be applied on: pandas numpy scikit-learn cupy Brian #4: difftastic - structural diff “Difftastic is a structural diff tool that understands syntax.” “Difftastic detects the language, parses the code, and then compares the syntax trees.” Interesting story about building difftastic For one off git diff replacement use GIT_EXTERNAL_DIFF=difft git diff or GIT_EXTERNAL_DIFF="difft --syntax-highlight=off" git diff To always use difft with git, see https://difftastic.wilfred.me.uk/git.html Extras Brian: Oh My Git! - An open source game about learning Git! Python 3.11.0 is up to rc2 Michael: NextDNS Joke: I mean, who's wrong?
For all the amazing powers of Python, deploying packaged apps that leverage native OS-level capabilities isn't one of them. But it can be done and we have a great guest, Rhet Turnbull, here to tell us how he built his distributable macOS app Textinator that uses macOS's native vision recognition framework through Python. Links from the show Rhet Turnbull on Twitter: @RhetTurnbull Textinator app: github.com Homebrew Python Is Not For You: justinmayer.com asdf: asdf-vm.com Space Force: spaceforce.com TextSniper app: textsniper.app Apple's Natural Language ML: developer.apple.com Apple's Vision ML: developer.apple.com py2app: py2app.readthedocs.io py2exe: pypi.org pyinstaller: pyinstaller.org RUMPS: github.com Michael's RUMPS app - URLify: github.com Home Brew: brew.sh pipx: github.com Gooey: github.com PLS CLI: github.com textX: pypi.org Join Space Force: spaceforce.com Beeware: beeware.org Watch this episode on YouTube: youtube.com Episode transcripts: talkpython.fm --- Stay in touch with us --- Subscribe to us on YouTube: youtube.com Follow Talk Python on Twitter: @talkpython Follow Michael on Twitter: @mkennedy Sponsors Sentry Error Monitoring, Code TALKPYTHON Talk Python Training
When you think data exploration using Python, Jupyter notebooks likely come to mind. They are excellent for those of us who gravitate towards Python. But what about your everyday power user? Think of that person who is really good at Excel but has never written a line of code? They can still harness the power of modern Python using a cool application called Superset. This open source Python-based web app is all about connecting to live data and creating charts and dashboards based on it using only UI tools. It's super popular too with almost 50,000 GitHub stars. Its creator, Max Beauchemin is here to introduce it to us all. Links from the show Max on Twitter: @mistercrunch Superset: superset.apache.org 60 notebook environments: talkpython.fm SQL Fluff linter: sqlfluff.com DB API PEP: peps.python.org Preset Company: preset.io Watch this episode on YouTube: youtube.com Episode transcripts: talkpython.fm --- Stay in touch with us --- Subscribe to us on YouTube: youtube.com Follow Talk Python on Twitter: @talkpython Follow Michael on Twitter: @mkennedy Sponsors Sentry's DEX Conference Talk Python Training
Watch the live stream: Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Brian #1: Can Amazon's CodeWhisperer write better Python than you? Brian Tarbox “Despite the clickbait-y title, whether CW's code is better or worse than mine is at the margins and not really important. What is significant is that it has the potential to save me a ton of time and mental space to focus on improving, refactoring and testing. It's making me a better programmer by taking on some of the undifferentiated heavy lifting.” Some decent code generation, starting with Amazon API examples. The generated dataclass method was neat, but really, the comment “prompt” probably took as much time to write as the code would have. The generated test case is workable, but I would not consider that a good test. Perhaps don't lump together construction, attribute access, and tests for all methods in one test function. That said, I've seen way worse test methods in my career. So, decent starting point. Related and worth listening to: Changelog #506: Stable Diffusion breaks the internet w/ Simon Willison Mostly an episode about AI generated art. There is a bit of a tie in to AI code generation, the ethics around it, and making sure you walk up the value chain. I'm planning on playing with GitHub CoPilot. I've been reluctant in the past, but Simon's interview is compelling to combine experienced engineering skill with AI code generation to possibly improve productivity. Simon does warn against possible abuse by Junior devs and the “just believe the code” problem that we also see with “copy from StackOverflow” situations. Michael #2: Apache Superset Apache Superset is a modern data exploration and visualization platform An intuitive interface for visualizing datasets and crafting interactive dashboards A wide array of beautiful visualizations to showcase your data Code-free visualization builder to extract and present datasets A world-class SQL IDE for preparing data for visualization, including a rich metadata browser A lightweight semantic layer which empowers data analysts to quickly define custom dimensions and metrics Out-of-the-box support for most SQL-speaking databases Seamless, in-memory asynchronous caching and queries An extensible security model that allows configuration of very intricate rules on who can access which product features and datasets. Integration with major authentication backends (database, OpenID, LDAP, OAuth, REMOTE_USER, etc) The ability to add custom visualization plugins An API for programmatic customization Brian #3: Recipes from Python SQLite docs Redowan Delowar Expanding on sqlite3 Python docs with more examples, including Executing individual and batch statements Applying user-defined callbacks: scalar and aggregate scalar example shows using a sha256 function to hash passwords as their inserted into the database Enabling tracebacks when callbacks raise an error Transforming types between SQLite and Python Implementing authorization control … much more … This is great for not only learning SQLite, but also, since these kinds of topics exist in other databases, learning about databases. AND a great example of learning a subsystem by creating little code snippets to check your understanding of something. One mod I would do in practice is to write these examples as pytest functions, because I can then run them individually while keeping a bunch in the same file.
We are on the edge of a major jump in Python performance. With the work done by the Faster CPython team and Python 3.11 due out in around a month, your existing Python code might see an increase of well over 25% in speed with no changes. One of the main reasons is its new specializing, adaptive interpreter. This episode is about that new feature and a great tool called Specialist which lets you visualize how Python is speeding up your code and where it can't unless you make minor changes. Its creator, Brandt Bucher is here to tell us all about. Links from the show Brandt Bucher: github.com Specialist package: github.com Faster CPython: github.com Faster CPython Ideas: github.com pymtl package: pypi.org PeachPy: github.com Watch this episode on YouTube: youtube.com Episode transcripts: talkpython.fm --- Stay in touch with us --- Subscribe to us on YouTube: youtube.com Follow Talk Python on Twitter: @talkpython Follow Michael on Twitter: @mkennedy Sponsors Microsoft RedHat Talk Python Training
Watch the live stream: Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Michael #1: PythonAnywhere: Our Commitment to Providing Free Accounts via Matthew Kramer In light of Heroku's cancelling their free tiers… They believe free tiers are important for beginners Two part solution: Limit outbound internet access for free accounts “Proof of life” to keep running - 3 months for apps, 1 yr for accounts BTW, they were acquired by Anaconda Inc. Brian #2: ruff: An extremely fast Python linter, written in Rust. Announcement article: Python tooling could be much, much faster Charlie Marsh Quite the star history, as it's a new repo as of Aug 30. Now at 1.8k. It is extremely fast. I installed it and tried it on a small project. It ran so fast I thought it didn't do anything. I went and added some errors to convince myself it was running. $ time flake8 src tests ... flake8 src tests 0.29s user 0.02s system 98% cpu 0.311 total $ time ruff src/ tests/ ... ruff src/ tests/ 0.01s user 0.01s system 162% cpu 0.011 total Michael #3: Meta spins off PyTorch Foundation to make AI framework vendor neutral PyTorch, which powers Tesla Autopilot and 150K other projects, will join the Linux Foundation. Its governing board includes representatives from Nvidia, Meta, Google, Microsoft, Amazon, and AMD. The PyTorch Foundation will strive to adhere to four principles, Remaining open Maintaining neutral branding Staying fair Forging a strong technical identity According to Meta, the transition to the PyTorch Foundation will not affect any existing PyTorch code Brian #4: Two string resources Python String Methods to Know Trey Hunner F-Strings Number Formatting Cheat Sheet Brian Allan Extras Brian: In Feb, on episode 271, we talked about Seaborn's new object interface Well, it's out now in seaborn 0.12 Interesting discussion about lazy imports. Other than that, I'm good with your extra.
Watch the live stream: Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Special guest: Seth Larson Brian #1: Test your packages and wheels I've been building some wheels the last couple of weeks with various tools: flit, flit-core, and flit build hatch, hatchling, and hatch build setuptools, build_meta, and python -m build There are a few projects I've used to make sure my projects are in good shape wheel-inspect - you can inspect within Python code through inspect_wheel() function that converts to json. Or use on the command line with wheel2json check-wheel-contents - a linter for wheels tox - easily test the building, installation, and running of a package locally I actually start here, then utilize the other two tools Should have been obvious, but it wasn't to me Projects saved on git (such as gitHub) don't keep wheels in git. (this was obvious) When installing from git using pip install git+https://path/to/git/repo.git Your local pip will run the packaging backend to build the wheel before installing. Yet another way to test packaging. Michael #2: The Jupyter+git problem is now solved Jupyter notebooks don't work with git by default (they inherently have meaningless conflicts). With nbdev2, the Jupyter+git problem has been totally solved. Uses a set of hooks which provide clean git diffs, solve most git conflicts automatically, and ensure that any remaining conflicts can be resolved entirely within the standard Jupyter notebook environment. The techniques used to make the merge driver work are quite fascinating Seth #3: Help us test system trust stores in Python Package aiming to replace certifi called “truststore”, use system trust stores for HTTPS instead of a static list of certificates. Problem truststore is solving usually manifests in corporate networks: “unable to get local issuer certificate”. Experimental support added to pip to prove the implementation Users can try out the functionality and report issues. Brian #4: Making plots in your terminal with plotext Bob Belderbos Tutorial on using plotext - that's one t in the middle With the rise of CLI usage, plots are a nice addition. Bob's plot is great, but check out the options in the plotext docs lots-o-plots streaming data images subplots so fun Michael #5: jinja2-fragments Carson from HTMX (see podcast and course) wrote about template fragments. My jinja_partials project sorta fulfills this, but not really. I had a nice discussion with Sergi Pons Freixes who uses jinja_partials about this. He created Jinja2 fragments Seth #6: SLSA 3 Generic Builder for GitHub Actions GA Supply chain Levels for Software Artifacts, or SLSA (“salsa”) Tools to attest to and verify “provenance” of artifacts, ie “where it came from” Prove cryptographically that artifacts are built from a specific GitHub repository, commit, tag. Another future defense against stolen PyPI credentials/accounts. Generic builder means you can sign anything, like wheels/sdists Extras Brian: Bring your pytest books to PyBay, if you want them signed. I'm only bringing a small amount. I'll be presenting "Sharing is Caring - pytest fixture edition” at 3:05 “Experts Panel on Testing in Python” at 7:00 And be a zombie on my 8 am flight back unless I can change my reservation. That's this weekend, Sat Sept 10, in SF Michael: Heroku announces plans to eliminate free plans Banned paywalls PyPI phisher identified: Actor Phishing PyPI Users Identified and Actors behind PyPI supply chain attack have been active since late 2021 Major Python CVE: CVE-2020-10735: Prevent DoS by large int[HTML_REMOVED]str conversions Seth: Pyxel, retro game engine for Python, v1.8.0 added experimental web support with WASM Joke: Dev just after work
Terminals seem like the very lowest common denominator for software platforms. They have to work over SSH. They only show text. You can't do much with them. Or can you? Will McGugan and team have been building Textual (based on Rich) which looks more like an animated web app than a terminal app. And he has learned a bunch of lessons trying to maximize terminal based apps. He's here to share his 7 lessons he's learned while building a modern TUI (text user interface) framework. Links from the show Will McGugan: @willmcgugan 7 things I've learned building a modern TUI framework post: textualize.io Prior Talk Python Episode: talkpython.fm Textualize: textualize.io Kitty terminal: sw.kovidgoyal.net Pydantic Immutability: pydantic-docs.helpmanual.io Monodraw: monodraw.helftone.com Async's lru cache: github.com Rich CLI: github.com Nerd Fonts: nerdfonts.com Oh My Posh: ohmyposh.dev Python Object Allocator ASCII Art: github.com Balsamiq wireframes: balsamiq.com Watch this episode on YouTube: youtube.com Episode transcripts: talkpython.fm --- Stay in touch with us --- Subscribe to us on YouTube: youtube.com Follow Talk Python on Twitter: @talkpython Follow Michael on Twitter: @mkennedy Sponsors Microsoft Sentry's DEX Conference AssemblyAI Talk Python Training
Watch the live stream: Watch on YouTube About the show Sponsored by the IRL Podcast from Mozilla Michael #1: Careful with that PyPI email via John Hagen There is a widespread Phishing attack going on against PyPI users. The PyPA is currently tweeting about it: https://twitter.com/pypi/status/1562442188285308929 Brian #2: IEEE Top Programming Languages 2022 : Python's still No. 1, but employers love to see SQL skills by Stephen Cass Related: The Rise of SQL It's become the second programming language everyone needs to know by Rina Diane Caballar Good to see Python on top for Spectrum and Trending But interesting to see growth and strength in SQL SQL is actually top for Jobs SQL is a skill you can't ignore. Not only are relational databases just as important for large systems, they're increasingly more important for small and even local systems, and are ever growing the responsibility of developers, not left to database specialists. Will #3: Using Mypy in production at Spring by Charlie Marsh Michael #4: Django 4.1 Yes, I'm a bit slow to notice this, from August 3, 2022. Big deal for us async folks! Asynchronous ORM interface: QuerySet now provides an asynchronous interface for all data access operations. Asynchronous handlers for class-based views: View subclasses may now define async HTTP method handlers: Also: Validation of Constraints: Check, unique, and exclusion constraints defined in the Meta.constraints option are now checked during model validation. Check out Chris' Django: Getting Started course at Talk Python. Brian #5: You Should Be Using Python's Walrus Operator - Here's Why by Martin Heinz A fun look at some places where I've never considered using := Examples reusing a value while building a list regular expression match results cleaning up while loops (ok, that I'm using already, but it's great) accumulating data in place named values in f-strings for multiple formatting. wow, super cool. … Will #6: Humre By Al Sweigart Author of "Automate the Boring Stuff with Python" Human readable regular expressions§ Joke: Password PR
Do you write web apps in Django? The framework has come a long way lately with versions 3 and 4 adopting many of the modern Python capabilities (async, for example). But there are so many other libraries and apps that you can use to do more with less code in plugin new functionality. I'm happy to have Christopher Trudeau here on talk Python to take us through his 17 favorite libraries you should be using in Django. Links from the show Chris on Twitter: @cltrudeau Django: Getting Started Course (by Chris): training.talkpython.fm Foundational libraries: coverage: coverage.readthedocs.io Sphinx: sphinx-doc.org Sphinx-rtd-theme: github.com pudb: documen.tician.de tox: tox.wiki Pillow (sort of Django, needed by ImageField): github.com Django libraries: Django Ninja: django-ninja.rest-framework.com DRF: django-rest-framework.org Grappelli: github.com django-import-export: github.com Django Debug Toolbar: github.com Django local flavor: github.com Django admin-extra-buttons: github.com django-awl: github.com django-airplane: github.com Django Extensions: github.com django-allauth: github.com awesome-django: github.com ‘Unstoppable' Python: infoworld.com asciimatics: github.com Watch this episode on YouTube: youtube.com --- Stay in touch with us --- Subscribe to us on YouTube: youtube.com Follow Talk Python on Twitter: @talkpython Follow Michael on Twitter: @mkennedy Sponsors IRL Podcast Microsoft AssemblyAI Talk Python Training
Watch the live stream: Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Brian #1: Uncommon Uses of Python in Commonly Used Libraries by Eugene Yan Specifically, Using relative imports Example from sklearn's base.py from .utils.validation import check_X_y from .utils.validation import check_array “Relative imports ensure we search the current package (and import from it) before searching the rest of the PYTHONPATH. “ For relative imports, we have to use the from .something import thing form. We cannot use import .something since later on in the code .something isn't valid. There's a good discussion of relative imports in pep 328 Michael #2: Skyplane Cloud Transfers Skyplane is a tool for blazingly fast bulk data transfers in the cloud. Skyplane manages parallelism, data partitioning, and network paths to optimize data transfers, and can also spin up VM instances to increase transfer throughput. You can use Skyplane to transfer data: Between buckets within a cloud provider Between object stores across multiple cloud providers (experimental) Between local storage and cloud object stores Skyplane takes several steps to ensure the correctness of transfers: Checksums, verify files exist and match sizes. Data transfers in Skyplane are encrypted end-to-end. Security: Encrypted while in transit and over TLS + config options Brian #3: 7 things I've learned building a modern TUI framework by Will McGugan Specifically, DictViews are amazing. They have set operations. Example of using items() to get views, then ^ for symmetric difference (done at the C level): # Get widgets which are new or changed print(render_map.items() ^ new_render_map.items()) Lots of other great topics in the article lru_cache is fast Unicode art in addition to text in doc strings The fractions module and a cool embedded video demo of some of the new css stuff in Textual Python's object allocator ascii art Michael #4: ‘Unstoppable' Python Python popularity still soaring: ‘Unstoppable' Python once again ranked No. 1 in the August updates of both the Tiobe and Pypl indexes of programming language popularity. Python first took the top spot in the index last October, becoming the only language besides Java and C to hold the No. 1 position. “Python seems to be unstoppable,” said the Tiobe commentary accompanying the August index. In the alternative Pypl Popularity of Programming Language index, which assesses language popularity based on Google searches of programming language tutorials, Python is way out front. Extras Brian: Matplotlib stylesheets can make your chart look awesome with one line of code. But it never occurred to me that I could write my own style sheet. Here's an article discussing creation of custom matplotlib stylesheets The Magic of Matplotlib Stylesheets XKCD Plots Michael: Back on 295 we talked about Flet. We now have a Talk Python episode on it (live and polished versions). Joke: Rakes and AWS
Have you heard of Flutter? It's a modern and polished UI framework to write mobile apps, desktop apps, and even web apps. While interesting, you may have kept your distance because Flutter is a Dart language-based framework. But with the project we're covering today, Flet, many Flutter UIs can now be written in pure Python. Flet is a very exciting development in the GUI space for Python devs. And we have the creator, Feodor Fitsner, here to take us through it. Links from the show Feodor on GitHub: github.com Flet: flet.dev Flutter: flutter.dev Dart: dart.dev Flet Tutorials: flet.dev It's All Widgets Showcase: itsallwidgets.com Roadmap: flet.dev pglet: pglet.io Flutter Flow Designer: flutterflow.io Fluent UI for Flutter Showcase App: bdlukaa.github.io macOS UI: pub.dev Flet Mobile Strategy: flet.dev Michael's flutter doctor output: flutter-doctor.png Pyscript: pyscript.net Watch this episode on YouTube: youtube.com Episode transcripts: talkpython.fm --- Stay in touch with us --- Subscribe to us on YouTube: youtube.com Follow Talk Python on Twitter: @talkpython Follow Michael on Twitter: @mkennedy Sponsors Sentry's DEX Conference IRL Podcast AssemblyAI Talk Python Training
Watch the live stream: Watch on YouTube About the show Sponsored by the IRL Podcast from Mozilla Michael #1: SQLCodeGen via Josh Thurston This is a tool that reads the structure of an existing database and generates the appropriate SQLAlchemy model code, using the declarative style if possible. This tool was written as a replacement for sqlautocode, which was suffering from several issues (including, but not limited to, incompatibility with Python 3 and the latest SQLAlchemy version). Features: Supports SQLAlchemy 1.4.x Produces declarative code that almost looks like it was hand written Produces PEP 8 compliant code Accurately determines relationships, including many-to-many, one-to-one Automatically detects joined table inheritance Excellent test coverage Brian #2: The death of setup.py*, long live pyproject.toml for Python-only projects Juan Luis Cano Rodriguez tweet pip install --``editable . now works with setuptools, as of version 64.0.0 To be clear, setup.cfg also not required. So everything can be in pyproject.toml The * part: projects with non-Python bits may still need setup.py See also the newly updated tutorial by the PyPA: Packaging Python Projects Now with absolutely no mention of setup.py or setup.cfg It's all pyproject.toml Commentary: For Python only projects, is setuptools a decent flit contender??? stay tuned Michael #3: aiocache via Owen Lamont In the same vein as async-cache you might also be interested in aiocache. It has some cool functionality like an optional Redis backend for multi process caching. his library aims for simplicity over specialization. All caches contain the same minimum interface which consists on the following functions: add: Only adds key/value if key does not exist. get: Retrieve value identified by key. set: Sets key/value. multi_get: Retrieves multiple key/values. multi_set: Sets multiple key/values. exists: Returns True if key exists False otherwise. increment: Increment the value stored in the given key. delete: Deletes key and returns number of deleted items. clear: Clears the items stored. raw: Executes the specified command using the underlying client. Brian #4: Hatch : a modern, extensible Python project manager Another flit contender? While reading Packaging Python Projects tutorial update, I noticed some examples for hatchling, as an alternative to setuptools, flit-core, and pdm. Played with it some, but still have some exploring to do. features Standardized build system with reproducible builds by default Robust environment management with support for custom scripts Easy publishing to PyPI or other sources includes --repo flag to be able to publish to alternative indices. Awesome for internal systems. Version management Configurable project generation with sane defaults Responsive CLI, ~2-3x faster than equivalent tools This sounds great. I haven't verified this Commentary: Good to see more packaging tools and user workflow explorations around packaging. Extras Michael: M1 Support for PyPy Announced (via PyCoders) Joke: I am the docs
PyPI has been in the news for a bunch of reasons lately. Many of them good. But also, some with a bit of drama or mixed reactions. On this episode, we have Dustin Ingram, one of the PyPI maintainers and one of the directors of the PSF, here to discuss the whole 2FA story, securing the supply chain, and plenty more related topics. This is another important episode that people deeply committed to the Python space will want to hear. Links from the show Dustin on Twitter: @di_codes Hardware key giveaway: pypi.org OpenSSF funds PyPI: openssf.org James Bennet's take: b-list.org Atomicwrites (left-pad on PyPI): reddit.com 2FA PyPI Dashboard: datadoghq.com github 2FA - all users that contribute code by end of 2023: github.blog GPG - not the holy grail: caremad.io Sigstore for Python: pypi.org pip-audit: pypi.org PEP 691: peps.python.org PEP 694: peps.python.org Watch this episode on YouTube: youtube.com --- Stay in touch with us --- Subscribe to us on YouTube: youtube.com Follow Talk Python on Twitter: @talkpython Follow Michael on Twitter: @mkennedy Sponsors RedHat IRL Podcast AssemblyAI Talk Python Training
Watch the live stream: Watch on YouTube About the show Sponsored by the IRL Podcast from Mozilla Brian #1: Pip constraints files by luminousmen You can put some constraints on your dependencies with a constraints file. “Constraints files are requirements files that only control which version of a requirement is installed, not whether it is installed or not. “ Syntax is a subset of requirements.txt syntax but all the restrictions seem reasonable, considering must have a name can't be editable can't specify extras (that one is maybe slightly weird) You can put --constraint constraints.txt right at the top of your requirements.txt file or specify it on command line, pip install --constraint constraints.txt -r requirements.txt Or, my favorite, stick it at the top of requirements.in file. yes. pip-compile correctly handles constraints when generating requirements.txt. Example requirements.in --constraint constraints.txt typer constraints.txt click
Pydantic has become a core building block for many Python projects. After 5 years, it's time for a remake. With version 2, the plan is to rebuild the internals (with benchmarks already showing a 17x performance improvement) and clean up the API. Sounds great, but what does that mean for us? Samuel Colvin, the creator of Pydantic, is here to share his plan for Pydantic v2. Links from the show Samuel on Twitter: @samuel_colvin Pydantic v2 plan: pydantic-docs.helpmanual.io Py03: pyo3.rs FastAPI: fastapi.tiangolo.com Beanie: github.com SQLModel: sqlmodel.tiangolo.com Speedate: docs.rs Pytests running on Pydantic in browser: githubproxy.samuelcolvin.workers.dev JSON to Pydantic tool: jsontopydantic.com Pyscript: pyscript.net Michael's Pyscript + WebAssembly: Python Web Apps video: youtube.com Watch this episode on YouTube: youtube.com Episode transcripts: talkpython.fm --- Stay in touch with us --- Subscribe to us on YouTube: youtube.com Follow Talk Python on Twitter: @talkpython Follow Michael on Twitter: @mkennedy Sponsors RedHat Microsoft AssemblyAI Talk Python Training
Every year, the Python core developers and a few other key players in the Python ecosystem meet to discuss the pressing issues and important advancements at an event called the Python Language Summit. While Python is a community known for openness, this meeting is typically held behind closed doors mostly for efficiency's sake. On this episode, we'll give you a look behind that door. We have Alex Waygood here on this episode to break it down for us and give a look inside the summit. Links from the show Alex on Twitter: @alexwaygood 2022 Python Language Summit: pyfound.blogspot.com Individual Talks Python without the GIL: pyfound.blogspot.com Reaching a per-interpreter GIL: pyfound.blogspot.com The "Faster CPython" project: 3.12 and beyond: pyfound.blogspot.com WebAssembly: Python in the browser and beyond: pyfound.blogspot.com F-strings in the grammar: pyfound.blogspot.com Cinder Async Optimizations: pyfound.blogspot.com The issue and PR backlog: pyfound.blogspot.com The path forward for immortal objects: pyfound.blogspot.com Sponsor: Reflect.run demo video: youtube.com Sponsor: Reflect.run sign up: app.reflect.run Sponsor: Microsoft for Startups Founder's Hub: startups.microsoft.com Watch this episode on YouTube: youtube.com --- Stay in touch with us --- Subscribe to us on YouTube: youtube.com Follow Talk Python on Twitter: @talkpython Follow Michael on Twitter: @mkennedy Sponsors Reflect.run Microsoft AssemblyAI Talk Python Training
Watch the live stream: Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Michael #1: Specialist: Python 3.11 perf highlighter via Alex Waygood Visualize CPython 3.11's specializing, adaptive interpreter.
Every year, the PSF and JetBrains team up to do a Python community survey. The most recent one was Fall of 2021. For this episode, I've gathered a great group of Python enthusiasts to discuss the results. I think you'll really enjoy the group discussion on this episode. Links from the show Guests Gina Häußge: @foosel Emily Morehouse-Valcarcel: @emilyemorehouse Tonya Sims: @TonyaSims Brett Cannon: @brettsky Jay Miller: @kjaymiller Paul Everitt: @paulweveritt 2021 Survey Results: jetbrains.com Watch this episode on YouTube: youtube.com Episode transcripts: talkpython.fm --- Stay in touch with us --- Subscribe to us on YouTube: youtube.com Follow Talk Python on Twitter: @talkpython Follow Michael on Twitter: @mkennedy Sponsors Sentry Error Monitoring, Code TALKPYTHON RedHat AssemblyAI Talk Python Training
Watch the live stream: Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Special guest: Ashley Anderson Ashley #1: PSF security key giveaway for critical package maintainers Giving away 4000 2FA hardware keys Surely a team effort but I found it via @di_codes twitter (Dustin Ingram) links to previous talks on PyPI/supply chain security Interesting idea for helping with supply-chain vulnerabilities At least one dev pulled a critical package in response Previously: I don't have any critical projects Armin Ronacher has an interesting take Michael #2: PyLeft-Pad via Dan Bader Markus Unterwaditzer was maintaining atomicwrites More on how this relates to a project (Home Assistant) I wonder if PyPI will become immutable once an item is published Brian #3: FastAPI Filter Suggested and created by Arthur Rio “I loved using django-filter with DRF and wanted an equivalent for FastAPI.” - Arthur Add query string filters to your api endpoints and show them in the swagger UI. Supports SQLAlchemy and MongoEngine. Supports operators: gt, gte, in, isnull, it, lte, not/ne, not_in/nin Ashley #4: Tools for building Python extensions in Rust PyO3 pyo3 - Python/Rust FFI bindings nice list of examples people might recognize in the PyO3 README Pydantic V2 will use it for pydantic-core maturin - PEP 621 wheel builder (pyproject.toml) pretty light weight, feels like flit for Rust or python/Rust rust-numpy (+ndarray) for scientific computing setuptools-rust for integrating with existing Python projects using setuptools Rust project and community place high value on good tooling, relatively young language/community with a coherent story from early on Rust macro system allows for really nice ergonomics (writing macros is very hard, using them is very easy) The performance/safety/simplicity tradeoffs Python and Rust make are very different, but both really appeal to me - Michael #5: AutoRegEx via Jason Washburn Enter an english phrase, it'll try to generate a regex for you You can do the reverse too, explain a regex You must sign in and are limited to 100 queries / [some time frame] Related from Simon Willison: Using GPT-3 to explain how code works Brian #6: Anaconda Acquires PythonAnywhere Suggested by Filip Łajszczak See also Anaconda Acquisition FAQs from PythonAnywhere blog From announcement: “The acquisition comes on the heels of Anaconda's release of PyScript, an open-source framework running Python applications within the HTML environment. The PythonAnywhere acquisition and the development of PyScript are central to Anaconda's focus on democratizing Python and data science.” My take: We don't hear a lot about PA much, even their own blog has had 3 posts in 2022, including the acquisition announcement. Their home page boasts “Python versions 2.7, 3.5, 3.6, 3.7 and 3.8”, although I think they support 3.9 as well, but not 3.10 yet, seems like from the forum. Also, no ASGI, so FastAPI won't work, for example. Still, I think PA is a cool idea, and I'd like to see it stay around, and stay up to date. Hopefully this acquisition is the shot in the arm it needed. Extras Michael: Python becomes the most sought after for employers hiring (by some metric) Ashley: PEP691 JSON Simple API for PyPI Rich Codex - automatic terminal “screenshots” Joke: Neta is a programmer
Deploying and managing your application after you create it can be a big challenge. Cloud platforms such as Azure have literally hundreds of services. Which ones should you choose? How do you link them together? In this episode, Anthony Shaw and Shayne Boyer share a new CLI tool and template they've created for jump starting you use of modern Python apps and deploying them to Azure. We're talking FastAPI, Beanie and MongoDB, async and await, Bicep DevOps, automated CI/CD pipelines and more. Plus we catch up on other Python work happening that Anthony is involved with. If you're interested in deploying or structuring modern Python apps, you'll find some interesting take aways from our conversation. Links from the show Anthony on Twitter: @anthonypjshaw Shayne Boyer: @spboyer Azure azd CLI tools: aka.ms Beanie ODM: github.io Pydantic: helpmanual.io Give me back my monolith article: craigkerstiens.com Python creator Guido van Rossum joins Microsoft: techcrunch.com Making Python Faster with Guido and Mark episode: talkpython.fm Watch this episode on YouTube: youtube.com Episode transcripts: talkpython.fm --- Stay in touch with us --- Subscribe to us on YouTube: youtube.com Follow Talk Python on Twitter: @talkpython Follow Michael on Twitter: @mkennedy Sponsors Sentry Error Monitoring, Code TALKPYTHON NordVPN AssemblyAI Talk Python Training
Watch the live stream: Watch on YouTube About the show Sponsored by Microsoft for Startups Founders Hub. Brian #1: rich-codex by Phil Ewels suggested by Will McGugan “A GitHub Action / command-line tool which generates screen grab images of a terminal window, containing command outputs or code snippets.” Generate images from commands embedded in markdown files, like README.md, for example. Searches through markdown files for stuff like: ![cat cat.txt | lolcat -S 1](img/cat.svg) then runs the command, and generates the image. Can be done within a GitHub action Can also send code snippets or json to rich-cli, then generate an image. You can also have commands in a config file, Very easy to use, makes very professional looking images for documentation, that's always up to date. Michael #2: Pydastic via Roman Right, by Rami Awar Pydastic is an elasticsearch python ORM based on Pydantic. Core Features Simple CRUD operations supported Sessions for simplifying bulk operations (a la SQLAlchemy) Dynamic index support when committing operations More on Elasticsearch here Brian #3: 3 Things to Know Before Building with PyScript by Braden Riggs Package indentation matters Local file access is possible. [HTML_REMOVED] - numpy - pandas - paths: - /views.csv [HTML_REMOVED] DOM manipulation has interesting conventions For buttons, you can include pys-onClick=”your_function” parameter to trigger python functions when clicked. For retrieving user input from within the [HTML_REMOVED] tag document.getElementById(‘input_obj_id').value can retrieve the input value. And Finally pyscript.write(“output_obj_id”, data) can write output to a tag from within the [HTML_REMOVED] tag. Michael's Pyscript videos Python + pyscript + WebAssembly: Python Web Apps, Running Locally with pyscript Python iOS Web App with pyscript and offline PWAs Michael #4: disnake via Sean Koenig disnake is a modern, easy to use, feature-rich, and async-ready API wrapper for Discord. Features: Modern Pythonic API using async/await syntax Sane rate limit handling that prevents 429 errors Command extension to aid with bot creation Easy to use with an object oriented design Optimized for both speed and memory Quickstart Commands API Extras Michael: Scholarships for upcoming FastAPI + MongoDB live course Humble Bundle for Python 2022 Michael's crazy earbuds (UE Fits) Joke: Better than a wage increase
Often when we learn about or work with Math, it's done so in a very detached style. You might learn the rules and techniques for differentiation, for example. But how often do you get to apply them to meaningful and interesting problems? In this episode, we have Vince Knight and Geraint Palmer on to discuss solving a wide variety of applied and approachable math problems using Python. Whether you're deeply into math or not so much, I think there is a lot to enjoy from this episode. Links from the show Applied Mathematics with Open-Source Software: taylorfrancis.com Book source files: ithub.com Vince on Twitter: @drvinceknight Geraint on Twitter: @geraintpalmer Traces Package: traces.readthedocs.io A Beautiful Mind: wikipedia.org Nashpy: github.com e: The Story of a Number: amazon.com SymPy episode: talkpython.fm 8451: 8451.com Stack Overflow Trends: stackoverflow.com PYCON UK 2017: Python for conducting operational research in healthcare: youtube.com Ciw package: github.com Python ternary: github.com Michael's in-person FastAPI course: maven.com Reimbursement templates for our courses Expense a Course at Talk Python: zoho.com Expense Course Bundle at Talk Python: zoho.com Expense Cohort Course at Talk Python: zoho.com Watch this episode on YouTube: youtube.com Episode transcripts: talkpython.fm --- Stay in touch with us --- Subscribe to us on YouTube: youtube.com Follow Talk Python on Twitter: @talkpython Follow Michael on Twitter: @mkennedy Sponsors RedHat Python at Scale AssemblyAI Talk Python Training
I'm sure you're familiar with package managers for your OS even if you don't use them. On macOS we have Homebrew, Chocolatey on Windows, and apt, yum, and others on Linux. But if you want to install Python applications, you typically have to fallback to managing them with pip. Maybe you install them for your account with the --user flag. But with pipx you get a clean, isolated install for every Python application that you use. And if you distribute Python apps, pipx is a definitely worth considering as a channel. Links from the show Chad Smith: @cs01_software Pipx: github.com Entry Points: dev.to Python Packaging Dashboard: chadsmith.dev MKDocStrings: mkdocstrings.github.io gdbgui: github.com termpair: github.com httpie: httpie.io pls (ls-replacement): dhruvkb.github.io Glances: nicolargo.github.io Watch this episode on YouTube: youtube.com Episode transcripts: talkpython.fm --- Stay in touch with us --- Subscribe to us on YouTube: youtube.com Follow Talk Python on Twitter: @talkpython Follow Michael on Twitter: @mkennedy Sponsors Mergify Python at Scale AssemblyAI Talk Python Training
Watch the live stream: Watch on YouTube About the show Sponsored by us! Support our work through: Our courses at Talk Python Training Test & Code Podcast Patreon Supporters Special guest: Nick Muoh Brian #1: picologging From a tweet by Anthony Shaw From README.md “early-alpha” stage project with some incomplete features. (cool to be so up front about that) “Picologging is a high-performance logging library for Python. picologging is 4-10x faster than the logging module in the standard library.” “Picologging is designed to be used as a drop-in replacement for applications which already use logging, and supports the same API as the logging module.” Now you've definitely got my attention. For many common use cases, it's just way faster. Sounds great, why not use it? A few limitations listed: process and thread name not captured. Some logging globals not observed: logging.logThreads, logging.logMultiprocessing, logging.logProcesses Logger will always default to the Sys.stderr and not observe (emittedNoHandlerWarning). Michael #2: CheekyKeys via Prayson Daniel What if you could silently talk to your computer? CheekyKeys uses OpenCV and MediaPipe's Face Mesh to perform real-time detection of facial landmarks from video input. The primary input is to "type" letters, digits, and symbols via Morse code by opening and closing your mouth quickly for . and slightly longer for -. Most of the rest of the keyboard and other helpful actions are included as modifier gestures, such as: shift: close right eye command: close left eye arrow up/down: raise left/right eyebrow … Watch the video where he does a coding interview for a big tech company using no keyboard. Nick #3: Is Google's LaMDA Model Sentient? authored by Richard Luscombe (The Guardian) The Google engineer who thinks the company's AI has come to life Transcript of conversation Brian #4: richbench Also from Anthony “A little Python benchmarking tool.” Give it a list of (first_func, second_func, “label”), and it times them and prints out a comparison. Simple and awesome. def sort_seven(): """Sort a list of seven items""" for _ in range(10_000): sorted([3,2,4,5,1,5,3]) def sort_three(): """Sort a list of three items""" for _ in range(10_000): sorted([3,2,4]) __benchmarks__ = [ (sort_seven, sort_three, "Sorting 3 items instead of 7") ] Michael #5: typeguard A run-time type checker for Python Three principal ways to do type checking are provided, each with its pros and cons: Manually with function calls @typechecked decorator import hook (typeguard.importhook.install_import_hook()) Example: @typechecked def some_function(a: int, b: float, c: str, *args: str) -> bool: ... return retval Nick #6: CustomTkinter A modern and customizable python UI-library based on Tkinter. Extras Michael: OpenSSF Funds Python and Eclipse Foundations - OpenSSF's Alpha-Omega Project has committed $400K to the Python Software Foundation (PSF), in order to create a new role which will provide security expertise for Python, the Python Package Index (PyPI), and the rest of the Python ecosystem, as well as funding a security audit. (via Python Weekly) Nick: Terms of Service Didn't Read - Terms of Service; Didn't Read” (short: ToS;DR) is a young project started in June 2012 to help fix the “biggest lie on the web”: almost no one really reads the terms of service we agree to all the time. Joke: Serverless A DevOps approach to COVID-19
You may have heard of the Bloomberg terminal. It's expensive software that can monitor and analyze real-time financial market data and place trades on the electronic trading platform. But have you heard of OpenBB? It's similar software for real-time and long term analysis for finance and investing. The difference is it's open source and built entirely with Python and gives you access to analyze a massive amount of real-time and historical data using the full Python data science stack. On this episode, we have one of the cofounders, James Maslek here to give us a look inside this cool piece of Python-based software. Links from the show James Maslek: linkedin.com OpenBB: openbb.co OpenBB Feature Gallery: openbb.co $8.5M seed funding announcement: openbb.co/blog How to get rich talk by Naval (less money-focused than the title implies): youtube.com Watch this episode on YouTube: youtube.com Episode transcripts: talkpython.fm --- Stay in touch with us --- Subscribe to us on YouTube: youtube.com Follow Talk Python on Twitter: @talkpython Follow Michael on Twitter: @mkennedy Sponsors Sentry Error Monitoring, Code TALKPYTHON Python at Scale AssemblyAI Talk Python Training