C++ style pass by reference - Ideas - Discussions on Python.org
Dec 18, 2022 ... I propose specifying a function parameter as being pass-by-reference, using the notation “&name” instead of “name”.
Dec 18, 2022 ... I propose specifying a function parameter as being pass-by-reference, using the notation “&name” instead of “name”.
hello: str = "hello" # original type: str hello_mutable: mutable<str> = "hello".to_mutable_copy() # internally converts to a type "mutable", with args (generics) of (str,). My library primarily does work-arounds for function cases right now using decorators.
Sep 27, 2023 ... However, this does not work because type checkers consider the assigned value to be a variable. The following code snippet illustrates it: def ...
I prefer the parameters of a function (with their documentation) to be listed explicitly in the function’s documentation. This is in contrast with man-style, which describes the positionals in prose. Compare open (what I call man-style) with numpy.linalg.norm (what I say employs an explicit list).
Dec 20, 2022 ... I imagine it would be more complex to write a code ... Several of the examples against quote reuse have minimal code being executed to interpolate ...
Python type checkers already exhibit a certain degree of type inference, the most obvious cases being lambdas (in some cases) and local variables. It might be useful if we had type inference for function (and method) return types.
Mar 2, 2021 ... (I have seen discussions on python-dev to change the exact mechanism, storing code objects instead of strings, but that won't change the fact ...
Source code: Lib/string.py String constants: The constants defined in this module are: Custom String Formatting: The built-in string class provides the ability to do complex variable substitutions ... Oh, and the colon marks the start of the format spec: [":" format_spec].
Sep 22, 2026 ... To make that easier, we introduce helper functions similar to annotationlib.get_annotations , which perform those computations under the hood.
Take this example, assuming that ReturnType refers to the return type of the enclosing function or method, this should type check just fine. from typing import List, Union.
Jun 7, 2023 ... and it means that you're supposed to pass a sequence of strings as the x parameter to that function. For instance, Python lists are a type of ...
Apr 30, 2025 ... Sample implementation. I've implemented a variant of this as an internal magic_open() function. Source code: cpython/Lib ...