Right-justifying a number with dot leaders
In terms of efficiency, the second form is probably slightly better, as it creates fewer string objects:

def float_rjust(value, width, precision=2, fillchar=' ', separator='', sign=''):
    #[sign][#][0][width][,][.precision][type]
    spec = '{{:{1}{2}{3}.{4}f}}'.format(  # 1
        sign,
        width,
        separator,
        precision
    )  # 2
    value = spec.format(value)  # 3 - slight refactor for clarity
    return value.rjust(width, fillchar)  # 4   


vs.

def float_rjust(value, width, precision=2, fillchar=' ', separator='', sign=''):
    #[[fill]align][sign][#][0][width][,][.precision][type]
    spec = '{{:{0}&gt;{1}{2}{3}.{4}f}}'.format(  # 1
        fillchar,
        sign,
        width,
        separator,
        precision
    )  # 2
    return spec.format(value)  # 3


In general terms, I would use e.g. rjust only where that was the only formatting I required; it seems awkward to split the formatting into two steps.



However, I would probably rearrange this completely. You have combined two steps that I think should probably be separate: creating a specification, and applying it to an object.

Using format(value, spec) rather than spec.format(value) (i.e. the format function vs. the str.format method) lets you simplify the spec (getting rid of the extra braces):

def float_spec(width, precision=2, fillchar=' ', separator='', sign=''):
    """Create a specification for formatting floats."""
    return '{}&gt;{}{}{}.{}f'.format(fillchar, sign, width, separator, precision)


You can now inline the format call:

&gt;&gt;&gt; print format(123.456, float_spec(width=10, fillchar='.'))
....123.46


For greater efficiency, as float_spec would return equal (but not identical) strings for the same inputs, you could add memoization/caching. You could also add validation (of either the parameters or created specs) to ensure that it outputs a valid specification for format.