# cf.Units.formatted

`Units.``formatted`(names=None, definition=None)

  Formats the string stored in the `units` attribute in a standardized manner. The `units` attribute is modified in place and its new value is returned.

  Parameters: | names: `bool`, optional Use unit names instead of symbols. definition: `bool`, optional The formatted string is given in terms of basic units instead of stopping any expansion at the highest level possible.
  Returns: | out: `str` or `None` The formatted string. If the units have not yet been set, then `None` is returned.
  Examples: |

      >>> u = Units('W')
      >>> u.units
      'W'
      >>> u.units = u.format(names=True)
      >>> u.units
      'watt'
      >>> u.units = u.format(definition=True)
      >>> u.units
      'm2.kg.s-3'
      >>> u.units = u.format(names=True, definition=True)
      'meter^2-kilogram-second^-3'
      >>> u.units = u.format()
      >>> u.units
      'W'

      >>> u.units='dram'
      >>> u.format(names=True)
      '1.848345703125e-06 meter^3'

  Formatting is also available during object initialization:

      >>> u = Units('m/s', format=True)
      >>> u.units
      'm.s-1'

      >>> u = Units('dram', names=True)
      >>> u.units
      '1.848345703125e-06 m3'

      >>> u = Units('Watt')
      >>> u.units
      'Watt'

      >>> u = Units('Watt', formatted=True)
      >>> u.units
      'W'

      >>> u = Units('Watt', names=True)
      >>> u.units
      'watt'

      >>> u = cf.Units('Watt', definition=True)
      >>> u.units
      'm2.kg.s-3'

      >>> u = cf.Units('Watt', names=True, definition=True)
      >>> u.units
      'meter^2-kilogram-second^-3'