PEP8 compatible naming convention for actual word selection in Python

I need a better way to name everything in Python. Yes, Ive read PEP8 , Spolskis wonderful outfit , and various other articles. But Im looking for more recommendations when choosing the actual words.

And yes I know

Stupid reconciliation is the Hobgoblin of Little Minds.

But you can maintain compatibility with PEP8, etc. and still don't have consistent variable / method / class names that are easy to remember. As agreed, I mean that if you were offered the same solution twice, you would give the same name.

As an example, there are several methods compatible with PEP8 to indicate the following elements:

  • the number of columns in the table
  • current column number
  • column object
  • column amount

Yes, of course, it’s easy to decide to use something like num_coland count_colrather than col_numand col_count(or vv). But I would like to see an example that has seen some testing / refinement over time. I often start with this agreement, and then it begins to collapse when I venture into a new area.

I assume that what I am looking for is not only what the / root / tag / suffix prefix (which was partially discussed for Apps Hungarian in the Spolsky article) should do, but (many) examples for each or a rule for generating everyone.

+3
source share
3 answers

, - . Spolsky , . , , ; , - , .

- . -, ( , ); , , - , . , , ( , , ).

, , , len(table) , sum(column) column.sum() ; - for ( c column).

+4

, , , , . , .

, col_num - . ? .

- . , , , . . -ed -d. , ....

, num_col - . ? . , num_of_cols. - recd_date rcvd_date, rec_date rcv_date.

-s -d , , , . , , .

, . . recd , , , . , , . dba , , , .

+2

.

.

"", "", "", " "

"", "", "," "

"", "", "," "

"", "-", "," "

. .

, - "" "" .

, . "Total", "Count", "Non-Underscore", "Columns", "In Tables", "With Even-Length Names", " ", "Keyed by", "Mother Maiden Name".

, , "" , .

Keep trying. It is always fun and games until someone meets a counter example.

You can keep trying or just use simple, clear names. If the volume of names is small (for example, a small function of a method), do not “remember” anything. All this is clearly visible in the 20 lines of code that make up the function of the method.

+1
source

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


All Articles