[Python-ideas] Re: timedelta.strptime() and timedelta.strftime()

2023-02-02 Thread Thomas Mc Kay
Here's a fourth way I've seen, that I forgot to mention (mostly a variation of Solution 2, above): ``` delta = datetime.strptime('05:20:25', '%H:%M:%S') - datetime.strptime('00:00:00', '%H:%M:%S') ``` ___ Python-ideas mailing list --

[Python-ideas] timedelta.strptime() and timedelta.strftime()

2023-02-02 Thread Thomas Mc Kay
I was looking for a simple intuitive way to parse a timedelta from a string. The best I could find feels clunky at best: https://stackoverflow.com/questions/4628122/ Solution 1 looks like this: ``` from datetime import datetime, timedelta t = datetime.strptime('05:20:25', '%H:%M:%S') delta =

[Python-ideas] Re: PEP 671: Syntax for late-bound function argument defaults

2021-10-23 Thread Thomas Mc Kay
Love the proposed syntax, it's clear and visible without being verbose. I was a bit worried with the "=:" syntax as, at first glance, it can be easily mistaken with a regular "=" but you can't miss "=>". Also, I think the syntax fits really well with the meaning of the operator, which is

[Python-ideas] Re: Fwd: [Python-Dev] Re: Semi-proposal: Tagged None

2021-10-21 Thread Thomas Mc Kay
Sorry I posted a bit fast, my two example above should read: class Foo: def __init__(self, bar=42, baz=None): self.bar = bar self.baz = baz # def do_something(self, bar_override=None, baz_override=None) ... And the second one: class Missing: pass MISSING =

[Python-ideas] Re: Fwd: [Python-Dev] Re: Semi-proposal: Tagged None

2021-10-21 Thread Thomas Mc Kay
+1 for me on the usefulness of having a way to express "Missing Data". One common use-case I encounter is in function signatures when one wants arguments that are meant as overrides: class Foo: def __init__(self, bar=42, baz=None): self.bar = bar self.baz = baz