x = 3.14159265
print(f'pi = {x:.2f}')
print( 'pi = %0.2f' % x)
ten = 10
print(f'x = {x:.2f}')
print('x = %0.2f' % x)
Create a timezone
object which you can pass to datetime()
or datetime.now()
.
from datetime import datetime, timezone, timedelta
# offset is in seconds
def make_tz(offset):
return timezone(timedelta(seconds=offset))
# UTC -400
x = -4 * 60 * 60
datetime.now(tzinfo=make_tz(x))
__init_subclass__
Is called
when a class is sub-classed. It is always a classmethod
and accepts keyword
arguments from the subclass parameters.