On Fri, 24 Mar 2023 at 13:02, Will Bradley <derivativedude...@gmail.com> wrote: > It would be nice if I could just write "birthDate": > date.strftime(r'%m/%d/%Y') as str, like in C#.
I'm sure it would - for you. Unfortunately it would most definitely NOT be nice to write: with something as str: and then be unsure whether you're casting or assigning. Python's "as" keyword usually indicates a name binding ("import x as y", "except Exception as e", etc), not a type cast. Improve your type hinting upstream (by proper use of typeshed), to avoid the need for these casts. Needing to cast at time of call is usually a bad sign - it means that not only can you not figure out the type from the function call (normally the most common way to get typing information), you also can't figure it out from usage. ChrisA _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/G7WRX57EQYRR7P6JELXKHKTAZ76FUDDL/ Code of Conduct: http://python.org/psf/codeofconduct/