Python Icon

Python

Python is a dynamically typed programming language.
284 Stories
All Topics

Command line interface github.com

AirDrop files directly from your CLI with OpenDrop

OpenDrop is a command-line tool that allows sharing files between devices directly over Wi-Fi. Its unique feature is that it is protocol-compatible with Apple AirDrop which allows to share files with Apple devices running iOS and macOS.

Super cool, but with a disclaimer: this is the result of reverse engineering the transfer protocol, so the odds of it being flakey (especially as Apple ships OS updates) are high. It’d be rad if Apple would publish an AirDrop-compatible specification for the community to rally around.

You know, like they did with FaceTime. 😉

Django djangoproject.com

Django 4.0 released

Highlights include built-in support for caching with Redis, more easily customizable forms and error lists, and standardizing Django’s timezone implementation to align with the Python standard library’s implementation. for the full list of goodies, check the release notes. Congrats to the entire Django team and community on the big release!

Side note: we haven’t done an episode on Django for many moons. Are we due? Who’d be the perfect guest you’d love to hear from on the topic?

Python github.com

Improve your Python regex skills with 75 interactive exercises

When I was in college my professor tried teaching us regular expressions: the theory, the algebra, all that. I left dumbfounded. When I hit the Real World I quickly ran into many practical use cases where a regular expression helped me solve a problem. That’s when I finally grokked them.

If you want to improve your understanding (and deployment of) regular expressions to solve problems, but don’t have a use case at the moment… here’s a whole bunch of them for you to practice on in the meantime.

Brett Cannon snarky.ca

Selecting a programming language can be a form of premature optimization

The bulk of this post by Brett Cannon is a detailed argument that Python makes sense to select even for projects with known performance concerns, but I got my money’s worth from the concept in the title and opener:

… it dawned on me that the problem is people are not treating language selection as potential form of premature optimization: if you select a programming language based on your preconceived notions of how a language performs, you will never know if the language that might be a better, more productive fit for your developers would have actually worked out.

Ruby softwaredoug.com

Ruby vs Python comes down to the for loop

Doug Turnbull breaks down a major difference between two beloved programming languages in how they handle iteration.

Python embraces for. Objects tell for how to work with them, and the for loop’s body processes what’s given back by the object. Ruby does the opposite. In Ruby, for itself (via each) is a method of the Object. The caller passes the body of the for loop to this method.

He goes on to give examples and explain why each approach might map to different developers’ brains… differently. Here’s a succinct summary, if you don’t have time for the deeper discussion:

In Ruby, the objects control the affordances. In Python, the language does.

Python github.com

An open source, online reverse dictionary

This is the first time I’ve heard of a reverse dictionary, but now that I have… so cool!

Opposite to a regular (forward) dictionary that provides definitions for query words, a reverse dictionary returns words semantically matching the query descriptions.

Ever had a word on the tip of your tongue and you Just. Can’t. Think of it?! Reverse dictionary!

An open source, online reverse dictionary

Cryptocurrency github.com

Hummingbot – a client for crypto market making

Hummingbot integrates cryptocurrency trading on both centralized exchanges and decentralized protocols. It allows users to run a client that executes customized, automated trading strategies for cryptocurrencies.

We created Hummingbot to promote decentralized market-making: enabling members of the community to contribute to the liquidity and trading efficiency in cryptocurrency markets.

There are many arbitrage opportunities between centralized exchanges like Coinbase and Binance (which often have high liquidity) and decentralized exchanges like Loopring and Terra (which thus far rarely have high liquidity).

If you have the financial stomach for it, Hummingbot could help you take advantage of these opportunities while providing liquidity to the decentralized markets.

Python lukasz.langa.pl

Where does all the effort go? Looking at Python core developer activity

Łukasz Langa was tasked by the PSF to look at the state of CPython as an active software development project.

What are people working on? Which standard libraries require most work? Who are the active experts behind which libraries? Those were just some of the questions asked by the Foundation. In this post I’m looking into our Git repository history and our Github PR data to find answers.

Follow along as Łukasz explains how they gathered the data, analyzed it, and got answers to the questions above.

Raspberry Pi github.com

MagInkCal syncs your Google calendar with a framable e-ink display

This incredibly cool DIY e-ink calendar uses a Raspberry Pi Zero WH to do its thing. Here’s how it works:

Through PiSugar2’s web interface, the onboard RTC can be set to wake and trigger the RPi to boot up daily at a time of your preference. Upon boot, a cronjob on the RPi is triggered to run a Python script that fetches calendar events from Google Calendar for the next few weeks, and formats them into the desired layout before displaying it on the E-Ink display. The RPi then shuts down to conserve battery. The calendar remains displayed on the E-Ink screen, because well, E-Ink…

MagInkCal syncs your Google calendar with a framable e-ink display

Electron github.com

A desktop app for JupyterLab (based on Electron)

If you already know what JupyterLab is, then I don’t have to tell you why this might be exciting/useful. If you don’t, well, here’s what JupyterLab is:

JupyterLab is the next-generation user interface for Project Jupyter offering all the familiar building blocks of the classic Jupyter Notebook (notebook, terminal, text editor, file browser, rich outputs, etc.) in a flexible and powerful user interface. JupyterLab will eventually replace the classic Jupyter Notebook.

A desktop app for JupyterLab (based on Electron)

Will McGugan github.com

Free code reviews for open source Python projects

Will McGugan is a full-stack developer and Python expert who is offering up free reviews for any/all qualifying open source projects.What a great idea/service to the community!

The reviews will focus on API design and general architection of your project with a view to making them a) more maintainable b) future proof and c) user friendly, but will avoid anything that a linter could do for you. Reviews are intended to be constructive and hopefully give advice you can act on, but are in no way a “grade”.

I won’t need to run your code to do a review and reviews aren’t intended to fix bugs.

All reviews will be public and will be published in the repo in a markdown file. An exception would be for any security issues, where I would notify you first.

Not everyone all at once, now. There’s already quite a few requests in the queue.

Docker gitlab.com

Harbormaster – easily deploy many Docker-Compose apps on a single host

Here’s their pitch:

Do you have a home server you want to run a few apps on, but don’t want everything to
break every time you upgrade the OS? Do you want automatic updates but don’t want to buy
an extra 4 servers so you can run Kubernetes?

Do you have a work server that you want to run a few small services on, but don’t want
to have to manually manage it? Do you find that having every deployment action be in
a git repo more tidy?

Harbormaster is for you.

You create a YAML config file with all the git repos you want it to include and it’ll watch them for changes (on a timer) and do the necessary cloning/pulling, service restarting, etc. that needs doing to make it all run. Simple. Neat!

AI (Artificial Intelligence) github.com

Jina – build search-as-a-service powered by deep learning in just minutes

Jina calls itself a “cloud-native neural search framework”. What is neural search, exactly?

The core idea of neural search is to leverage state-of-the-art deep neural networks to build every component of a search system. In short, neural search is deep neural network-powered information retrieval. In academia, it’s often called neural IR.

And what can it do for you?

Thanks to recent advances in deep neural networks, a neural search system can go way beyond simple text search. It enables advanced intelligence on all kinds of unstructured data, such as images, audio, video, PDF, 3D mesh, you name it.

For example, retrieving animation according to some beats; finding the best-fit memes according to some jokes; scanning a table with your iPhone’s LiDAR camera and finding similar furniture at IKEA. Neural search systems enable what traditional search can’t: multi/cross-modal data retrieval.

This project looks quite established and collaborative. 172 contributors and counting…

Privacy github.com

A self-hosted, ad-free, privacy-respecting metasearch engine

Get Google search results, but without any ads, javascript, AMP links, cookies, or IP address tracking. Easily deployable in one click as a Docker app, and customizable with a single config file. Quick and simple to implement as a primary search engine replacement on both desktop and mobile.

Includes quick deployment to Heroku, Replit, and Fly. Or you can run it locally, of course via standard Python tooling or Docker.

Security github.com

A digital image forensic toolset

Sherloq is a personal research project about implementing a fully integrated environment for digital image forensics. It is not meant as an automatic tool that decide if an image is forged or not (that tool probably will never exist…), but as a companion in experimenting with various algorithms found in the latest research papers and workshops.

The original version was written in C++ in 2015, but a port to Python is in the works. It looks super useful, but buyer beware:

I’m happy to share my code and get in contact with anyone interested to improve or test it, but please keep in mind that this repository is not intended for distributing a final product, my aim is just to publicly track development of an unpretentious educational tool, so expect bugs, unpolished code and missing features! ;)

A digital image forensic toolset

Brett Cannon snarky.ca

Introducing the Python launcher for Unix

Brett Cannon:

… over 3 years ago I set out to re-implement the Python Launcher for Unix in Rust. On July 24, 2021, I launched 1.0.0 of the Python Launcher for Unix… This gives you a py command on Unix which will always use the newest version of Python.

He goes on to describe some workflow niceties that a built in and also what this project is not about:

The Launcher is purely a convenience and not meant to be The Launcher For All Things; this should never end up in a Docker container.

Ned Batchelder nedbatchelder.com

On reading code with your eyebrows

Ned Batchelder, after reading some code to termine whether or not it was “Pythonic”:

My first response was that I don’t like this code, because I had to read it with my eyebrows. That is, I furrow my brow, and read slowly, and scowl at the code as I puzzle through it. This code is dense and tricky.

Is it Pythonic? I guess in the sense that it uses a number of Python-specific constructs and tools, yes. But not in the sense of Python code being clear and straightforward. It uses Python thoroughly, but misses the spirit.

(He then rewrites it in a way that he likes. Which solution do you prefer?)

I’m no Pythonista, so I don’t know what is or isn’t “Pythonic”. However, I do know that I love the phrase, “read it with my eyebrows”, because I’ve quite literally done this my entire career. I used to invoke my eyebrows and conclude that I was just bad at reading code. Now when I invoke them I conclude that the code I’m reading is bad.

Martin Heinz martinheinz.dev

The unknown features of Python's `operator` module

At the first glance Python’s operator module might not seem very interesting. It includes many operator functions for arithmetic and binary operations and a couple of convenience and helper functions. They might not seem so useful, but with help of just a few of these functions you can make your code faster, more concise, more readable and more functional. So, in this article we will explore this great Python module and make the most out of the every function included in it.

Nikita Sobolev sobolevn.me

Typeclasses in Python

In this post, I explain what typeclasses are (an alternative to subtyping polymorphism) and how to use them. I give examples in 4 very different languages to show that this concept is universal. I also show that this idea is very pythonic by comparing our classes implementation with functools.singledispatch.

Check how easy it is to define a typeclass with classes:

from classes import AssociatedType, Supports, typeclass

class Greet(AssociatedType):
    """Special type to represent that some instance can `greet`."""

@typeclass(Greet)
def greet(instance) -> str:
    """No implementation needed."""

@greet.instance(str)
def _greet_str(instance: str) -> str:
    return 'Hello, {0}!'.format(instance)

def greet_and_print(instance: Supports[Greet]) -> None:
    print(greet(instance))

greet_and_print('world')
# Hello, world!

Check it out!

0:00 / 0:00