Lazy load of strings - Ideas - Discussions on Python.org
May 11, 2025 ... A modify existings internal type, PyUnicode , to include fields need for loading. This type will store: A reference to the loader function ( ...
May 11, 2025 ... A modify existings internal type, PyUnicode , to include fields need for loading. This type will store: A reference to the loader function ( ...
Propagating the exception by declaring it in the calling function’s return type. def myfun() -> str | Raises[ValueError]: return str(get_value()). Casting the return value of the function to one that does not raise. value = cast(int, get_value()).
Jan 2, 2023 ... Joining an array of arbitrary values using a string separator is, equally obviously, a fundamental method of arrays. ... write "\n".join(arr ...
I would like to be able to type a function that has multiple parameters, with the same generic variable, that only checks if the later parameters are compatible with the first. Proposal I propose by adding a bind_first …
May 3, 2023 ... Many functions expect parameters that are iterable and do not care if they are actually lists. But, instead of importing typing.
I have to write a simple function that returns a string. The string (in this example) is a city and a country e.g. London, England. I have done some other exercises where I return a formatted name e.g. Bob Johnson, but I cannot get this one right. Here is my codes so far
Mar 5, 2022 ... Of course, some types (like your “number, string”) are immutable, so you usually can't detect whether you get a copy or the same object, and ...
May 8, 2025 ... ... Python dictionary with string keys and string values). Then instead of CYOA code, you write code that performs actions using this data. And ...
I have a function which checks to see if a dictionary key exists. And if it doesn’t, it returns a blank string ''. But sometimes the value in the dict can be a string, float, or int. Or the key may not exist at all, which is where I’m having trouble.
Jul 20, 2022 ... replace() because this function changes a string to a different string. ... value (speaking in terms of passing by reference or passing by value).
Oct 19, 2025 ... length > 0 ) to test that an array a is not empty. You cannot write a.length or a – this does not work in boolean context. In Python you can ...