Найти - Пользователи
Полная версия: Spyder + Pylint = переменные в строчных или больших буквах
Начало » Инструментальные средства разработки » Spyder + Pylint = переменные в строчных или больших буквах
1
qman
Всем здрасте,
Раньше думал что принято писать переменные маленькими буквами, а сегодня узнал что наоборот. Установил IDE spyder, установил к нему pylint.
Написал
a = 5
b = 6
c = a + b
print c
В pylint нажал кнопку analyze, получил
No config file found, using default configuration
************* Module .temp
C: 9: Invalid name "a" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$)
C: 10: Invalid name "b" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$)
C: 11: Invalid name "c" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$)



Report

======

4 statements analysed.



Duplication
-----------

+-------------------------+------+---------+-----------+
| |now |previous |difference |
+=========================+======+=========+===========+
|nb duplicated lines |0 |0 |= |
+-------------------------+------+---------+-----------+
|percent duplicated lines |0.000 |0.000 |= |
+-------------------------+------+---------+-----------+

Raw metrics
----------

+----------+-------+------+---------+-----------+
|type |number |% |previous |difference |
+==========+=======+======+=========+===========+
|code |4 |28.57 |4 |= |
+----------+-------+------+---------+-----------+
|docstring |6 |42.86 |6 |= |
+----------+-------+------+---------+-----------+
|comment |1 |7.14 |1 |= |
+----------+-------+------+---------+-----------+
|empty |3 |21.43 |3 |= |
+----------+-------+------+---------+-----------+

Statistics by type

------------------

+---------+-------+-----------+-----------+------------+---------+
|type |number |old number |difference |%documented |%badname |
+=========+=======+===========+===========+============+=========+
|module |1 |1 |= |100.00 |0.00 |
+---------+-------+-----------+-----------+------------+---------+
|class |0 |0 |= |0.00 |0.00 |
+---------+-------+-----------+-----------+------------+---------+
|method |0 |0 |= |0.00 |0.00 |
+---------+-------+-----------+-----------+------------+---------+
|function |0 |0 |= |0.00 |0.00 |
+---------+-------+-----------+-----------+------------+---------+

Messages by category

--------------------

+-----------+-------+---------+-----------+
|type |number |previous |difference |
+===========+=======+=========+===========+
|convention |3 |3 |= |
+-----------+-------+---------+-----------+
|refactor |0 |0 |= |
+-----------+-------+---------+-----------+
|warning |0 |0 |= |
+-----------+-------+---------+-----------+
|error |0 |0 |= |
+-----------+-------+---------+-----------+

Messages
--------
+-----------+-----------+
|message id |occurences |
+===========+===========+
|C0103 |3 |
+-----------+-----------+

Global evaluation
-----------------
Your code has been rated at 2.50/10 (previous run: 2.50/10)
если переписать переменные большими буквами то
No config file found, using default configuration



Report

======

4 statements analysed.



Duplication

-----------


+-------------------------+------+---------+-----------+
| |now |previous |difference |
+=========================+======+=========+===========+
|nb duplicated lines |0 |0 |= |
+-------------------------+------+---------+-----------+
|percent duplicated lines |0.000 |0.000 |= |
+-------------------------+------+---------+-----------+






Raw metrics

-----------


+----------+-------+------+---------+-----------+
|type |number |% |previous |difference |
+==========+=======+======+=========+===========+
|code |4 |28.57 |4 |= |
+----------+-------+------+---------+-----------+
|docstring |6 |42.86 |6 |= |
+----------+-------+------+---------+-----------+
|comment |1 |7.14 |1 |= |
+----------+-------+------+---------+-----------+
|empty |3 |21.43 |3 |= |
+----------+-------+------+---------+-----------+






Statistics by type

------------------


+---------+-------+-----------+-----------+------------+---------+
|type |number |old number |difference |%documented |%badname |
+=========+=======+===========+===========+============+=========+
|module |1 |1 |= |100.00 |0.00 |
+---------+-------+-----------+-----------+------------+---------+
|class |0 |0 |= |0.00 |0.00 |
+---------+-------+-----------+-----------+------------+---------+
|method |0 |0 |= |0.00 |0.00 |
+---------+-------+-----------+-----------+------------+---------+
|function |0 |0 |= |0.00 |0.00 |
+---------+-------+-----------+-----------+------------+---------+






Messages by category

--------------------


+-----------+-------+---------+-----------+
|type |number |previous |difference |
+===========+=======+=========+===========+
|convention |0 |3 |-3.00 |
+-----------+-------+---------+-----------+
|refactor |0 |0 |= |
+-----------+-------+---------+-----------+
|warning |0 |0 |= |
+-----------+-------+---------+-----------+
|error |0 |0 |= |
+-----------+-------+---------+-----------+


Global evaluation
-----------------
Your code has been rated at 10.00/10 (previous run: 2.50/10)
то код приложения получает 10 баллов из 10, в предыдущем случае было 2,5. Поясните как принято писать переменные маленькими или большими буквами?
P.S. конечно пишу по привычке маленькими буквами, но почему pylint настроен наоборот!?
poltergeist
Видимо на уровне модуля pylint воспринимает эти переменные как константы, а они должны быть в верхнем регистре со знаком подчёркивания в качестве разделителя. Перенесите этот код в функцию и будет всё ок.
qman
poltergeist
Перенесите этот код в функцию и будет всё ок.
сделал так:
def asd():
a = 5
b = 6
c = a + b
return (c)

print asd()
результат тот же
No config file found, using default configuration
************* Module .temp
C: 8:asd: Missing docstring
C: 9:asd: Invalid name "a" (should match [a-z_][a-z0-9_]{2,30}$)
C: 10:asd: Invalid name "b" (should match [a-z_][a-z0-9_]{2,30}$)
C: 11:asd: Invalid name "c" (should match [a-z_][a-z0-9_]{2,30}$)



Report

======

6 statements analysed.



Duplication

-----------


+-------------------------+------+---------+-----------+
| |now |previous |difference |
+=========================+======+=========+===========+
|nb duplicated lines |0 |0 |= |
+-------------------------+------+---------+-----------+
|percent duplicated lines |0.000 |0.000 |= |
+-------------------------+------+---------+-----------+






Raw metrics

-----------


+----------+-------+------+---------+-----------+
|type |number |% |previous |difference |
+==========+=======+======+=========+===========+
|code |6 |40.00 |4 |+2.00 |
+----------+-------+------+---------+-----------+
|docstring |6 |40.00 |6 |= |
+----------+-------+------+---------+-----------+
|comment |1 |6.67 |1 |= |
+----------+-------+------+---------+-----------+
|empty |2 |13.33 |3 |-1.00 |
+----------+-------+------+---------+-----------+






Statistics by type

------------------


+---------+-------+-----------+-----------+------------+---------+
|type |number |old number |difference |%documented |%badname |
+=========+=======+===========+===========+============+=========+
|module |1 |1 |= |100.00 |0.00 |
+---------+-------+-----------+-----------+------------+---------+
|class |0 |0 |= |0.00 |0.00 |
+---------+-------+-----------+-----------+------------+---------+
|method |0 |0 |= |0.00 |0.00 |
+---------+-------+-----------+-----------+------------+---------+
|function |1 |0 |+1.00 |0.00 |0.00 |
+---------+-------+-----------+-----------+------------+---------+






Messages by category

--------------------


+-----------+-------+---------+-----------+
|type |number |previous |difference |
+===========+=======+=========+===========+
|convention |4 |0 |+4.00 |
+-----------+-------+---------+-----------+
|refactor |0 |0 |= |
+-----------+-------+---------+-----------+
|warning |0 |0 |= |
+-----------+-------+---------+-----------+
|error |0 |0 |= |
+-----------+-------+---------+-----------+






Messages

--------


+-----------+-----------+
|message id |occurences |
+===========+===========+
|C0103 |3 |
+-----------+-----------+
|C0111 |1 |
+-----------+-----------+






Global evaluation

-----------------

Your code has been rated at 3.33/10 (previous run: 10.00/10)
P.S. конечно можно забить и работать как раньше без pylint, но хотелось бы докопаться до ответа.
pasaranax
Результат совсем не тот же, читай внимательнее. Ключевые буквы здесь: {2,30}, то есть не следует делать однобуквенных переменных.
qman
pasaranax
Результат совсем не тот же, читай внимательнее. Ключевые буквы здесь: {2,30}, то есть не следует делать однобуквенных переменных.
спасибо.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB