1

I am creating two separate lists in which the elements are coming from the same table which is in mysql database. Some fields of the table i am storing in one list while the other fields in another list. As you see the naming of these lists look bad to me and hence i am thinking what could be the best naming convention in python i can give to these lists.

table_info1 = [source_system, filter_column, start_date, end_date, storage_account, database, table, dc,
                           environment, min_ts]
  
table_info2 = [target_container, last_run_date, history_load, source_table_type, source_sub_system,
                           username, password, azure_key, interval_days, key_str, schedule_tag]
  • 1
    Does this answer your question? [What is the naming convention in Python for variable and function names?](https://stackoverflow.com/questions/159720/what-is-the-naming-convention-in-python-for-variable-and-function-names) – ksohan Feb 15 '22 at 19:14
  • @ksohan actually the thing is that the lists are created from same table hence the above link is not useful – Travelling Days Feb 15 '22 at 19:24
  • @TravellingDays why does it matter that they are created from the same table? the same python naming conventions still hold. –  Feb 15 '22 at 19:39

2 Answers2

0

According to python's PEP 8: Function and Variable Names variable names should be lowercase, with words separated by underscores as necessary to improve readability. mixedCase is allowed only in contexts where that's already the prevailing style (e.g. threading.py), to retain backwards compatibility.

Therefore, the names of your lists should be meaningful variable names (what does each list represent?) in lowercase, separated by underscores, without numbers.

  • each list represent columns from database table. The table is same – Travelling Days Feb 15 '22 at 19:28
  • @TravellingDays I understand, but in order to give meaningful names to the lists - one needs to understand why are you creating the two lists in the first place, what is their user, why do you create them separately and not in one list, etc. Therefore, if @user18074821 is correct and `table_info1` describes the source and `table_info2` describes the target - it makes sense to call the lists `source_info` and `target_info`. –  Feb 15 '22 at 19:35
0

Call them source_info and target_info

user18074821
  • 196
  • 5