Re: str as param for timedelta

2006-01-27 Thread [EMAIL PROTECTED]
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 da

str as param for timedelta

2006-01-27 Thread Philipp
Hello Pythonistas I'm new to Python, I hope you understand my question. I would like to pass a parameter "gap" to a function. gap should be used there to create a timedelta Object. from datetime import * def f(gap): print (datetime.now() + datetime.timedelta(gap)) f('hours = -8') I r