Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the underscore naming convention for python

Shulou Source: shulou.com Published: 2022-06-03 17:38:43 10月03日 Update

This article is about how Python uses the underscore naming convention. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.

description

A single preunderlined_var for internal purposes.

Use var_when you want to use Python keywords as variables in your code.

Double pre-underscore is used for name modification__var.

Double underscore (before and after) is used for method name__var__.

Example 1

def _test_func(): Return 20_test_func()

output

20

Example 2

def test_function(list_): return list_* 2test_function([1,2,4,5])

output

[1, 2, 4, 5, 1, 2, 4, 5] Thank you for reading! About "python how to use underline naming convention" This article is shared here, I hope the above content can have some help for everyone, so that everyone can learn more knowledge, if you think the article is good, you can share it to let more people see it!

Tags: Underline convention content name instance more article output good practical code key keyword single variable article method purpose see knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Docker vpn Shulou Tech Info NVidia