fixes.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:skutil 作者: tgsmith61591 项目源码 文件源码
def is_iterable(x):
    """Python 3.x adds the ``__iter__`` attribute
    to strings. Thus, our previous tests for iterable
    will fail when using ``hasattr``.

    Parameters
    ----------

    x : object
        The object or primitive to test whether
        or not is an iterable.


    Returns
    -------

    bool
        True if ``x`` is an iterable
    """
    if isinstance(x, six.string_types):
        return False
    return hasattr(x, '__iter__')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号