python内置函数源码_python如何查看内置函数源码

如题,如何查看python内置函数的源码

举个例子:

# 该以什么样的方式,才能去看xrang的官方源码实现

for i in xrange(10):

print i

# 直接点进去的话,大多都是一些定义的方法名,而没有具体实现

# 就是想知道,如何去看具体实现,而不是下面那一堆 pass

class xrange(object):

"""

xrange(stop) -> xrange object

xrange(start, stop[, step]) -> xrange object

Like range(), but instead of returning a list, returns an object that

generates the numbers in the range on demand. For looping, this is

slightly faster than range() and more memory efficient.

"""

def __getattribute__(self, name): # real signature unknown; restored from __doc__

""" x.__getattribute__('name') <==> x.name """

pass

def __getitem__(self, y): # real signature unknown; restored from __doc__

""" x.__getitem__(y) <==> x[y] """

pass

def __init__(self, stop): # real signature unknown; restored from __doc__

pass

def __iter__(self): # real signature unknown; restored from __doc__

""" x.__iter__() <==> iter(x) """

pass

def __len__(self): # real signature unknown; restored from __doc__

""" x.__len__() <==> len(x) """

pass

@staticmethod # known case of __new__

def __new__(S, *more): # real signature unknown; restored from __doc__

""" T.__new__(S, ...) -> a new object with type S, a subtype of T """

pass

def __reduce__(self, *args, **kwargs): # real signature unknown

pass

def __repr__(self): # real signature unknown; restored from __doc__

""" x.__repr__() <==> repr(x) """

pass

def __reversed__(self, *args, **kwargs): # real signature unknown

""" Returns a reverse iterator. """

pass

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值