mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
words
This commit is contained in:
@@ -9,13 +9,13 @@ authors:
|
||||
|
||||
# No-async async with Python
|
||||
|
||||
A (reasonable) criticism of async is that it tends to proliferate in your code. In order to `await` something, your functions must be `async` all the way up the call-stack.
|
||||
A (reasonable) criticism of async is that it tends to proliferate in your code. In order to `await` something, your functions must be `async` all the way up the call-stack. This tends to result in you making things `async` just to support that one call that needs it or, worse, adding `async` just-in-case. Given that going from `def` to `async def` is a breaking change there is a strong incentive to go straight there.
|
||||
|
||||
Before you know it, you have adopted a policy of "async all the things".
|
||||
|
||||
<!-- more -->
|
||||
|
||||
Textual is very much an async framework, but doesn't *require* the app developer to use the `async` and `await` keywords. Async in Textual apps is entirely optional. This post is about how Textual accomplishes this async-agnosticism.
|
||||
Textual is an async framework, but doesn't *require* the app developer to use the `async` and `await` keywords (but you can if you need to). This post is about how Textual accomplishes this async-agnosticism.
|
||||
|
||||
!!! info
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
draft: false
|
||||
draft: false
|
||||
date: 2022-11-20
|
||||
categories:
|
||||
- DevLog
|
||||
@@ -30,7 +30,7 @@ There are a number of files and modules in [Textual](https://github.com/Textuali
|
||||
|
||||
## Loop first / last
|
||||
|
||||
How often do you find yourself looping over an iterable and needing to know if an element is the first and/or last in the sequence? It's a simple thing, but I find myself nedding this a *lot*, so I wrote some helpers in [_loop.py](https://github.com/Textualize/textual/blob/main/src/textual/_loop.py).
|
||||
How often do you find yourself looping over an iterable and needing to know if an element is the first and/or last in the sequence? It's a simple thing, but I find myself needing this a *lot*, so I wrote some helpers in [_loop.py](https://github.com/Textualize/textual/blob/main/src/textual/_loop.py).
|
||||
|
||||
I'm sure there is an equivalent implementation on PyPI, but steal this if you need it.
|
||||
|
||||
@@ -72,7 +72,7 @@ In Textual, we use a [LRUCache](https://github.com/Textualize/textual/search?q=L
|
||||
|
||||
## Color
|
||||
|
||||
Textual has a [Color](https://github.com/Textualize/textual/blob/main/src/textual/color.py) class which could be extracted in to a module of its own.
|
||||
Textual has a [Color](https://github.com/Textualize/textual/blob/main/src/textual/color.py) class which could be extracted in to a module of its own.
|
||||
|
||||
The Color class can parse colors encoded in a variety of HTML and CSS formats. Color object support a variety of methods and operators you can use to manipulate colors, in a fairly natural way.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user