On 12.05.2016 02:16, Alexander Belopolsky wrote:
On Wed, May 11, 2016 at 4:36 PM, Ian Kelly
mailto:ian.g.kelly@gmail.com> wrote: Still best to be explicit:
>>> sleep(timedelta(100))
It would be awesome if that actually worked.
FWIW, I would not mind seeing sleep() as a timedelta instance method:
timedelta(seconds=42).sleep()
Some would suggest that introducing a new protocol like - timedelta(seconds=42).__seconds__ defining an ABC - class SecondLike(abc.ABC): - @abc.abstractmethod - def __seconds__(self): - raise NotImplementedError defining an extraction function - def os.seconds... and let all stdlib functions which accepts integer/float seconds also accept SecondLike objects as the solution to the problem. I have to admit that I like your idea more. Sven