What's the advantage of a trailing underscore in Python naming?

后端 未结 3 1250
渐次进展
渐次进展 2021-01-17 21:06

I am used to naming Python arguments in this way:

my_argument=\'foo\'

what\'s the advantage if I do this instead:

my_argum         


        
3条回答
  •  太阳男子
    2021-01-17 21:24

    Usually naming conventions like this don't have any empiric purpose in python (i.e. they don't do anything special) aside from avoiding conflict between keywords. For example, you wouldn't name a variable class would you? You'd name it class_ to avoid conflict with the built-in keyword.

提交回复
热议问题