pep8

what is trailing whitespace and how can I handle this?

跟風遠走 提交于 2019-12-03 08:04:27
问题 some piece of my codes: if self.tagname and self.tagname2 in list1: try: question = soup.find("div", "post-text") title = soup.find("a", "question-hyperlink") self.list2.append(str(title)+str(question)+url) current += 1 except AttributeError: pass logging.info("%s questions passed, %s questions \ collected" % (count, current)) count += 1 return self.list2 pep8 warning is: trailing whitespace 37:try trailing whitespace 43:pass Can you please tell me what is this? 回答1: Trailing whitespace is

Visual studio code suppress pep8 warnings

≯℡__Kan透↙ 提交于 2019-12-03 06:32:28
问题 How can I suppress pep8 warnings, in Visual studio code? What I want to do is to suppress E501 warning I don't want to get warnings where my code length is more than 80 chars. I'm using Don Jayamanne's Python extension and here is my config file for vscode { "python.linting.pylintEnabled": false, "python.linting.pep8Enabled": true, "python.pythonPath": "/workspace/virtualenvs/abr/bin/python3", "python.linting.enabled": true } I know that there is one another option "python.linting.pep8Args":

Line is too long. Django PEP8

*爱你&永不变心* 提交于 2019-12-03 06:30:47
问题 PEP8 info: models.py:10:80: E501 line too long (83 > 79 characters) Models.py: field = TreeForeignKey('self', null=True, blank=True, related_name='abcdefgh') How to correctly write this line? 回答1: It's "correct", PEP8 just flags lines over 79 characters long. But if you're concerned about that, you could write it like this: field = TreeForeignKey('self', null=True, blank=True, related_name='abcdefgh') Or this: field = TreeForeignKey( 'self', null=True, blank=True, related_name='abcdefgh', )

Define functions with too many arguments to abide by PEP8 standard

删除回忆录丶 提交于 2019-12-03 06:10:33
问题 I have defined a function with a long list of arguments. The total characters in definition is above 80 and doesn't abide by PEP8. def my_function(argument_one, argument_two, argument_three, argument_four, argument_five): What can be the best approach to avoid horizontal scrolling. 回答1: An example is given in PEP 8: class Rectangle(Blob): def __init__(self, width, height, color='black', emphasis=None, highlight=0): So that is the official answer. Personally I detest this approach, in which

PyCharm and filters for external tools

让人想犯罪 __ 提交于 2019-12-03 05:57:56
I'm trying out PyCharm for Django development and so far am extremely happy. My team strictly follows PEP8 formatting and we use the pep8 command line program to check to make sure our code conforms. I've configured an external tool command to run pep8 and it works good. I see the capability to create filters that will cause the output to be parsed into something PyCharm can use. I've read the docs and searched Google but can't find an example to make this work. Docs are http://www.jetbrains.com/pycharm/webhelp/add-filter-dialog.html I'm using PyCharm 1.2 and the output filter I'm using looks

How to write a pep8 configuration (pep8.rc) file?

送分小仙女□ 提交于 2019-12-03 05:40:56
问题 I found the documentation for pep8 but wasn't able to understand how to write these. I couldn't even find any examples with options other than setting max-line-length and ignore. I am trying to write a .pep8.rc file in which, among other things, I need to do the following: enable show source enable statistics enable count exclude a directory (say, for example ./random ) Can somebody answer with an example or link to one? 回答1: The preferred way is to use a setup.cfg in the top-level of the

What PEP 8 guidelines do you ignore, and which ones do you stick to? [closed]

岁酱吖の 提交于 2019-12-03 04:43:33
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 years ago . Over the years, the more Python I write, the more I find myself agreeing with most of the guidelines, though I consistently and intentionally break some for my own reasons. I'd be curious to know what in PEP 8 (or other PEPs too maybe) people religiously stick to and why, and

PEP8 – import not at top of file with sys.path

北城余情 提交于 2019-12-03 02:55:31
问题 Problem PEP8 has a rule about putting imports at the top of a file: Imports are always put at the top of the file, just after any module comments and docstrings, and before module globals and constants. However, in certain cases, I might want to do something like: import sys sys.path.insert("..", 0) import my_module In this case, the pep8 command line utility flags my code: E402 module level import not at top of file What is the best way to achieve PEP8 compliance with sys.path modifications?

Disable pep8 check in syntastic for python files

守給你的承諾、 提交于 2019-12-03 02:14:13
I work with enough code that does not follow pep8 (that I cannot fix) and would like syntastic to not use the pep8 syntax checker. Any way to disable it? If your are using flake8 as a python syntax checker you could do it like this (put it into your vimrc or ftplugin/python.vim file): let g:syntastic_python_checkers=['flake8'] let g:syntastic_python_flake8_args='--ignore=E501,E225' You need to silence each error class explicitly (and cannot disable pep8 checking as a whole). See the flake8 documentation and pycodestyle documentation (used to be pep8) for all error and warning codes. Adding to

PEP 8, why no spaces around '=' in keyword argument or a default parameter value?

走远了吗. 提交于 2019-12-03 02:06:38
问题 Why does PEP 8 recommend not having spaces around = in a keyword argument or a default parameter value? Is this inconsistent with recommending spaces around every other occurrence of = in Python code? How is: func(1, 2, very_long_variable_name=another_very_long_variable_name) better than: func(1, 2, very_long_variable_name = another_very_long_variable_name) Any links to discussion/explanation by Python's BDFL will be appreciated. Mind, this question is more about kwargs than default values, i