# Buggy code
def display(self, msg=None, pos=None):
    """
    Use `self.sp` to display `msg` in the specified `pos`.

    Consider overloading this function when inheriting to use e.g.:
    `self.some_frontend(**self.format_dict)` instead of `self.sp`.

    Parameters
    ----------
    msg  : str, optional. What to display (default: `repr(self)`).
    pos  : int, optional. Position to `moveto`
      (default: `abs(self.pos)`).
    """
    if pos is None:
        pos = abs(self.pos)

    nrows = self.nrows or 20
    if pos >= nrows - 1:
        if pos >= nrows:
            return False
        if msg or msg is None:  # override at `nrows - 1`
            msg = " ... (more hidden) ..."

    if not hasattr(self, "sp"):
        raise TqdmDeprecationWarning(
            "Please use `tqdm.gui.tqdm(...)` instead of `tqdm(..., gui=True)`\n",
            fp_write=getattr(self.fp, "write", sys.stderr.write),
        )

    if pos:
        self.moveto(pos)
    self.sp(self.__repr__() if msg is None else msg)
    if pos:
        self.moveto(-pos)
    return True


# Traceback (AttributeError)
import tqdm, sys
print(tqdm.__version__, sys.version, sys.platform)
('4.26.0', '2.7.14 (default, Mar 22 2018, 15:04:47) \n[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]', 'darwin')
a = tqdm.tqdm([], disable=True)
print a
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/kratsg/.virtualenvs/pyhf/lib/python2.7/site-packages/tqdm/_tqdm.py", line 894, in __repr__
elapsed if elapsed is not None else self._time() - self.start_t,
AttributeError: 'tqdm' object has no attribute '_time'
str(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/kratsg/.virtualenvs/pyhf/lib/python2.7/site-packages/tqdm/_tqdm.py", line 894, in __repr__
elapsed if elapsed is not None else self._time() - self.start_t,
AttributeError: 'tqdm' object has no attribute '_time'
dir(a)
['__class__', '__del__', '__delattr__', '__dict__', '__doc__', '__enter__', '__eq__', '__exit__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_comparable', '_decr_instances', '_get_free_pos', '_instances', '_lock', 'clear', 'close', 'disable', 'external_write_mode', 'format_interval', 'format_meter', 'format_sizeof', 'get_lock', 'iterable', 'monitor', 'monitor_interval', 'moveto', 'n', 'pandas', 'pos', 'refresh', 'set_description', 'set_description_str', 'set_lock', 'set_postfix', 'set_postfix_str', 'status_printer', 'total', 'unpause', 'update', 'write']

# Fixed code
def display(self, msg=None, pos=None):
    """
    Use `self.sp` to display `msg` in the specified `pos`.

    Consider overloading this function when inheriting to use e.g.:
    `self.some_frontend(**self.format_dict)` instead of `self.sp`.

    Parameters
    ----------
    msg  : str, optional. What to display (default: `repr(self)`).
    pos  : int, optional. Position to `moveto`
      (default: `abs(self.pos)`).
    """
    if pos is None:
        pos = abs(self.pos)

    nrows = self.nrows or 20
    if pos >= nrows - 1:
        if pos >= nrows:
            return False
        if msg or msg is None:  # override at `nrows - 1`
            msg = " ... (more hidden) ..."

    if not hasattr(self, "sp"):
        raise TqdmDeprecationWarning(
            "Please use `tqdm.gui.tqdm(...)` instead of `tqdm(..., gui=True)`\n",
            fp_write=getattr(self.fp, "write", sys.stderr.write),
        )

    if pos:
        self.moveto(pos)
    self.sp(self.__str__() if msg is None else msg)
    if pos:
        self.moveto(-pos)
    return True