What is the basic principle for naming conventions in PEP 8?

In the PEP 8 Style Guide for Python Code , the first rule specified in the Naming Convention is the principle of redefinition.

Redefinition principle

Names visible to the user as public parts of the API must conform to conventions that reflect usage, not implementation.

The PEP guidelines do not provide any additional details or examples that have left me unsure of what this rule actually means.

What is the basic principle in PEP 8? When does this rule apply?

+3
source share
2 answers

, , , .

sorted() vs list.sort.

for element in sorted(my_list): 
    ...

:

for element in sort(my_list): 
    ...

for element in my_list.sort():
    ...

for element in my_list.sorted():
    ...

API , , . sorted .sort .

, Python /.

0

Python , , , - . Python ", " Python . , , , .

-1

Source: https://habr.com/ru/post/1689267/


All Articles