Python標準庫:內建函數callable(object),pythoncallable

來源:互聯網
上載者:User

Python標準庫:內建函數callable(object),pythoncallable

如果對象object參數是可以調用的對象,就返回True;否則返回False。不過要注意的是,當一個對象是可以調用的,並不表示調用該對象時執行一定成功,但不可調用的對象去調用時一定不會成功。如果類對象是一個類對象,那麼這個類是否重載有__call__()方法來決定,如果重載有這個方法就判斷為True。

例子:

#callable()函數a = 'abc'def f(a):    pass    print(callable(a), callable(f))

輸出結果如下:

False True



蔡軍生 QQ:9073204  深圳


python內建函數

我也在學python,一起討論討論?
 
python有內建函數這個名詞那就說明也有外置函數嘍?

python的內建函數built-in function是指在標準庫standard library中的內建函數。這些函數不屬於任何類或模組,可以直接調用,可以看成python語言不可分割的一部分吧。近似於關鍵字。
abs()
dict()
help()
min()
setattr()

all()
dir()
hex()
next()
slice()

any()
divmod()
id()
object()
sorted()

ascii()
enumerate()
input()
oct()
staticmethod()

bin()
eval()
int()
open()
str()

bool()
exec()
isinstance()
ord()
sum()

bytearray()
filter()
issubclass()
pow()
super()

bytes()
float()
iter()
print()
tuple()

callable()
format()
len()
property()
type()

chr()
frozenset()
list()
range()
vars()

classmethod()
getattr()
locals()
repr()
zip()

compile()
globals()
map()
reversed()
__import__()

complex()
hasattr()
max()
round()

delattr()
hash()
memoryview()
set()

標準庫中其他模組內的靜態方法等不屬於內建函數。

使用者自訂擴充的函數也不屬於內建。
=============
但在其他語言、其他環境下,內建函數的具體含義不同。
內建函數在概念上並沒有唯一專指,是合成詞,最好理解為“被內建了的一些函數”...餘下全文>>
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.