本文介紹了Python命名中尾隨下劃線有什么好處?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
我習(xí)慣用這種方式命名 Python 參數(shù):
I am used to naming Python arguments in this way:
my_argument='foo'
如果我這樣做有什么好處:
what's the advantage if I do this instead:
my_argument_='foo"
按照 PEP008 的建議?
as is recommended by PEP008?
尾隨下劃線一定有充分的理由,那是什么?
There must be a good reason for the trailing underscore, so what is it?
推薦答案
正是它在 PEP 中提供的內(nèi)容:它允許您使用原本會是 Python 關(guān)鍵字的東西.
Exactly what it gives in the PEP: it allows you to use something that would otherwise be a Python keyword.
as_
with_
for_
in_
這篇關(guān)于Python命名中尾隨下劃線有什么好處?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!