Philipp wrote:
> from datetime import *
>
> def f(gap):
> print (datetime.now() + datetime.timedelta(gap))
>
> f('hours = -8')
When you need a flexible input format, consider keyword arguments. In
this case, I would pass along the inputs to timedelta:
def from_now(**kwargs):
return datetime.now() + timedelta(**kwargs)
from_now(hours=8) returns datetime.now() + timedelta(hours=8), and the
function can now accept any of timedelta's arguments. For more on what
**kwargs means, see the tutorial:
http://docs.python.org/tut/node6.html#SECTION006720000000000000000
--
http://mail.python.org/mailman/listinfo/python-list