本文介紹了Python命名中尾隨下劃線有什么好處?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我習慣用這種方式命名 Python 參數:
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 中提供的內容:它允許您使用原本會是 Python 關鍵字的東西.
Exactly what it gives in the PEP: it allows you to use something that would otherwise be a Python keyword.
as_
with_
for_
in_
這篇關于Python命名中尾隨下劃線有什么好處?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!