• Re: Re: Any possible type alias that can also set a default value for a

    From Chris Angelico@21:1/5 to Karsten Hilbert on Thu Oct 19 18:12:33 2023
    On Thu, 19 Oct 2023 at 18:04, Karsten Hilbert <Karsten.Hilbert@gmx.net> wrote:

    or something like that. Basically, any way to avoid writing `= None` over and over again.

    Fundamentally no, at least not without some shenanigans. Type hints do
    not affect the regular running of the code,

    Except when they do ;-)

    ... depending on what counts as (valid) code ...

    In Python a distinction can be made between "runnable" and "valid" :-D


    Can you give a counter-example? I mean, yes, any code can be written
    that inspects the annotations at runtime and makes whatever changes it
    likes, but that's part of what I described as "shenanigans".

    ChrisA

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)