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 --
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 =
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
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 =
+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