This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a = { 10 } | |
| b = { 20 } | |
| print( ( a or [] ) + ( b or [] ) ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a = [ 10 ] | |
| b = { 20 } | |
| print( ( a or [] ) + ( b or [] ) ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a = [ 10 ] | |
| b = { 20 } | |
| print( a + b ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import ClassVar, Final, Self, Any | |
| class Interface: | |
| # Every subclass has a _name attribute (set by __init_subclass__) | |
| _name: ClassVar[Final[str]] | |
| # Registry of subclasses |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import Iterator | |
| def fib(n: int) -> Iterator[int]: | |
| a, b = 0, 1 | |
| while a < n: | |
| yield a | |
| a, b = b, a + b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cond = False | |
| print(1, *([2] if cond else []), 3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import Protocol, Callable | |
| # --- workflow contracts (the only supported implementation style) --- | |
| class SayHelloWorkflow(Protocol): | |
| def run(self, name: str) -> str: ... | |
| # A benefit to this class-based approach to defining workflows over the Go | |
| # SDK is that we can also raise type errors for missing query or signal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from __future__ import annotations | |
| from dataclasses import dataclass | |
| from typing import Protocol | |
| # --- "generated" RPC types (pretend these come from codegen) --- | |
| @dataclass(frozen=True) | |
| class HelloRequest: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import uuid | |
| from typing import reveal_type | |
| x = uuid.uuid4() | |
| reveal_type(x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import Any | |
| def fn(**kwargs: dict[str, Any]): | |
| ... | |
| fn(param=[1,2,3]) |
NewerOlder