A dziś napisałem trochę o kaczkotypowaniu i protokołach: https://niedzwiedz.blog/it/2025/03/06/protokoly-w-pythonie.html
#python #programming #typing #ducktyping
A dziś napisałem trochę o kaczkotypowaniu i protokołach: https://niedzwiedz.blog/it/2025/03/06/protokoly-w-pythonie.html
#python #programming #typing #ducktyping
To be precise, 3 bad rows out of 600M...
#ducktyping - talk to your kids about it before someone else does.
What's in a name? That which we call a duck
By any other name would quack the same;
So a sequence would, were it not a sequence call'd,
Retain that dear iterability which it bears
Without that title. Sequence, doff thy name,
And for that name which is no part of thee
give thy iterator to me.
Checking for an empty list in Python - Python Morsels (@treyhunner)
Various methods to check if a list is empty in Python:
➡️ checking the list's length,
➡️ evaluating the list's truthiness
➡️ comparing the list to another empty list
#Python #Truthiness #PEP8 #DuckTyping #Programming #PythonProgramming
https://www.pythonmorsels.com/checking-for-an-empty-list-in-python/
Another duck-typing 🦆 post. A few days ago, I covered the GetAwaiter method that allows adding await functionality to any type. Today, another feature that relies on the same construct.
Deconstruction is a feature that allows extracting separate values out of a tuple. But what if we would like to deconstruct a type that is a bit more complex than a tuple? We can do it with the help of duck typing.
Deconstruction will work if the compiler detects a Deconstruct method that matches the call that we are trying to make. For example, let's try to deconstruct a Process. See the example below.
We start the process and wait for it to exit. In 1️⃣, we would like to use deconstruction to assign Pid & ExitCode to two variables. It won't work out of the box. But we can write an extension method 2️⃣ that the compiler would be able to use to perform the deconstruction.
Docs 📑: https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/functional/deconstruct
Turns out duck typing is actually a way you can draw ducks with code: #DuckTyping #BingAI #Bing
@chaotin “Well if it smells like lemon cake and tastes a bit sour… 🤷♂️”
#DuckTyping : when you can't formalize a relationship between T and F
@TeethTeethTeeth if it walks like a duck. And talks like a duck. And looks like a duck.
.
..
...
..
.
It must be an #echidna