code: def to_bytes(value, string_pattern="{0}"):
      """Short-cut method to allow mixed value types to be converted to bytes.
  
      :param value: Value to be cast to bytes
      :type value: :class:`basestring`, :class:`int`, :class:`float`
      :param string_pattern: String format to allow printf style control of
                             bytes output.
      :type string_pattern: :class:`basestring`
  
      .. versionadded:: 0.6.4
      """
      return string_pattern.format(value).encode()
  
file_path: wand/wand/compat.py
imports: import collections
  import contextlib
  import io
  import sys
  import types
label_desc: Use image node_id 2 for calling a global function with example usage: to_bytes(value, string_pattern) and returns: string_pattern