A quick no-brainer:
some_float = 1234.5678
print '%02d' % some_float # 1234
some_float = 1234.5678
print '{WHAT?}'.format(some_float) # I want 1234 here too
Note: {:.0f} is not an option, because it rounds (returns 1235 in this example).
format(..., int(some_float)) is exactly the thing I'm trying to avoid, please don't suggest that.
"{:.0f}".format(1234.5678)is"1235", not"1234".int()or truncating it are the only options? Next step is to create a customfloat()subclass to customize the.__format__()hook.{some_var:d}work without extra conversions.