/usr/share/doc/phatch/html/other.pep8.html is in phatch-doc 0.2.7.1-3.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>pep8 — Phatch 0.2 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '0.2',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Phatch 0.2 documentation" href="index.html" />
<link rel="up" title="other" href="other.html" />
<link rel="next" title="pil_1_1_6" href="other.pil_1_1_6.html" />
<link rel="prev" title="findsystem" href="other.findsystem.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="other.pil_1_1_6.html" title="pil_1_1_6"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="other.findsystem.html" title="findsystem"
accesskey="P">previous</a> |</li>
<li><a href="index.html">Phatch 0.2 documentation</a> »</li>
<li><a href="other.html" accesskey="U">other</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="module-other.pep8">
<span id="pep8"></span><h1>pep8<a class="headerlink" href="#module-other.pep8" title="Permalink to this headline">¶</a></h1>
<p>Check Python source code formatting, according to PEP 8:
<a class="reference external" href="http://www.python.org/dev/peps/pep-0008/">http://www.python.org/dev/peps/pep-0008/</a></p>
<p>For usage and a list of options, try this:
$ python pep8.py -h</p>
<p>This program and its regression test suite live here:
<a class="reference external" href="http://github.com/jcrocholl/pep8">http://github.com/jcrocholl/pep8</a></p>
<p>Groups of errors and warnings:
E errors
W warnings
100 indentation
200 whitespace
300 blank lines
400 imports
500 line length
600 deprecation
700 statements</p>
<p>You can add checks to this program by writing plugins. Each plugin is
a simple function that is called for each line of source code, either
physical or logical.</p>
<p>Physical line:
- Raw line of text from the input file.</p>
<p>Logical line:
- Multi-line statements converted to a single line.
- Stripped left and right.
- Contents of strings replaced with ‘xxx’ of same length.
- Comments removed.</p>
<p>The check function requests physical or logical lines by the name of
the first argument:</p>
<p>def maximum_line_length(physical_line)
def extraneous_whitespace(logical_line)
def blank_lines(logical_line, blank_lines, indent_level, line_number)</p>
<p>The last example above demonstrates how check plugins can request
additional information with extra arguments. All attributes of the
Checker object are available. Some examples:</p>
<p>lines: a list of the raw lines from the input file
tokens: the tokens that contribute to this logical line
line_number: line number in the input file
blank_lines: blank lines before this one
indent_char: first indentation character in this file (‘ ‘ or ‘ ‘)
indent_level: indentation (with tabs expanded to multiples of 8)
previous_indent_level: indentation on previous line
previous_logical: previous logical line</p>
<p>The docstring of each check function shall be the relevant part of
text from PEP 8. It is printed if the user enables –show-pep8.
Several docstrings contain examples directly from the PEP 8 document.</p>
<p>Okay: spam(ham[1], {eggs: 2})
E201: spam( ham[1], {eggs: 2})</p>
<p>These examples are verified automatically when pep8.py is run with the
–doctest option. You can add examples for your own check functions.
The format is simple: “Okay” or error/warning code followed by colon
and space, the rest of the line is example source code. If you put ‘r’
before the docstring, you can use</p>
<blockquote>
<div>for newline, for tab and s</div></blockquote>
<p>for space.</p>
<dl class="class">
<dt id="other.pep8.Checker">
<em class="property">class </em><tt class="descclassname">other.pep8.</tt><tt class="descname">Checker</tt><big>(</big><em>filename</em><big>)</big><a class="headerlink" href="#other.pep8.Checker" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p>
<p>Load a Python source file, tokenize it, check coding style.</p>
<dl class="method">
<dt id="other.pep8.Checker.build_tokens_line">
<tt class="descname">build_tokens_line</tt><big>(</big><big>)</big><a class="headerlink" href="#other.pep8.Checker.build_tokens_line" title="Permalink to this definition">¶</a></dt>
<dd><p>Build a logical line from tokens.</p>
</dd></dl>
<dl class="method">
<dt id="other.pep8.Checker.check_all">
<tt class="descname">check_all</tt><big>(</big><big>)</big><a class="headerlink" href="#other.pep8.Checker.check_all" title="Permalink to this definition">¶</a></dt>
<dd><p>Run all checks on the input file.</p>
</dd></dl>
<dl class="method">
<dt id="other.pep8.Checker.check_logical">
<tt class="descname">check_logical</tt><big>(</big><big>)</big><a class="headerlink" href="#other.pep8.Checker.check_logical" title="Permalink to this definition">¶</a></dt>
<dd><p>Build a line from tokens and run all logical checks on it.</p>
</dd></dl>
<dl class="method">
<dt id="other.pep8.Checker.check_physical">
<tt class="descname">check_physical</tt><big>(</big><em>line</em><big>)</big><a class="headerlink" href="#other.pep8.Checker.check_physical" title="Permalink to this definition">¶</a></dt>
<dd><p>Run all physical checks on a raw input line.</p>
</dd></dl>
<dl class="method">
<dt id="other.pep8.Checker.readline">
<tt class="descname">readline</tt><big>(</big><big>)</big><a class="headerlink" href="#other.pep8.Checker.readline" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the next line from the input buffer.</p>
</dd></dl>
<dl class="method">
<dt id="other.pep8.Checker.readline_check_physical">
<tt class="descname">readline_check_physical</tt><big>(</big><big>)</big><a class="headerlink" href="#other.pep8.Checker.readline_check_physical" title="Permalink to this definition">¶</a></dt>
<dd><p>Check and return the next physical line. This method can be
used to feed tokenize.generate_tokens.</p>
</dd></dl>
<dl class="method">
<dt id="other.pep8.Checker.report_error">
<tt class="descname">report_error</tt><big>(</big><em>line_number</em>, <em>offset</em>, <em>text</em>, <em>check</em><big>)</big><a class="headerlink" href="#other.pep8.Checker.report_error" title="Permalink to this definition">¶</a></dt>
<dd><p>Report an error, according to options.</p>
</dd></dl>
<dl class="method">
<dt id="other.pep8.Checker.run_check">
<tt class="descname">run_check</tt><big>(</big><em>check</em>, <em>argument_names</em><big>)</big><a class="headerlink" href="#other.pep8.Checker.run_check" title="Permalink to this definition">¶</a></dt>
<dd><p>Run a check plugin.</p>
</dd></dl>
</dd></dl>
<dl class="function">
<dt id="other.pep8.blank_lines">
<tt class="descclassname">other.pep8.</tt><tt class="descname">blank_lines</tt><big>(</big><em>logical_line</em>, <em>blank_lines</em>, <em>indent_level</em>, <em>line_number</em>, <em>previous_logical</em>, <em>blank_lines_before_comment</em><big>)</big><a class="headerlink" href="#other.pep8.blank_lines" title="Permalink to this definition">¶</a></dt>
<dd><p>Separate top-level function and class definitions with two blank lines.</p>
<p>Method definitions inside a class are separated by a single blank line.</p>
<p>Extra blank lines may be used (sparingly) to separate groups of related
functions. Blank lines may be omitted between a bunch of related
one-liners (e.g. a set of dummy implementations).</p>
<p>Use blank lines in functions, sparingly, to indicate logical sections.</p>
<p>Okay: def a():n passnnndef b():n pass
Okay: def a():n passnnn# Foon# Barnndef b():n pass</p>
<p>E301: class Foo:n b = 0n def bar():n pass
E302: def a():n passnndef b(n):n pass
E303: def a():n passnnnndef b(n):n pass
E303: def a():nnnn pass
E304: @decoratornndef a():n pass</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.compound_statements">
<tt class="descclassname">other.pep8.</tt><tt class="descname">compound_statements</tt><big>(</big><em>logical_line</em><big>)</big><a class="headerlink" href="#other.pep8.compound_statements" title="Permalink to this definition">¶</a></dt>
<dd><p>Compound statements (multiple statements on the same line) are
generally discouraged.</p>
<p>While sometimes it’s okay to put an if/for/while with a small body
on the same line, never do this for multi-clause statements. Also
avoid folding such long lines!</p>
<p>Okay: if foo == ‘blah’:n do_blah_thing()
Okay: do_one()
Okay: do_two()
Okay: do_three()</p>
<p>E701: if foo == ‘blah’: do_blah_thing()
E701: for x in lst: total += x
E701: while t < 10: t = delay()
E701: if foo == ‘blah’: do_blah_thing()
E701: else: do_non_blah_thing()
E701: try: something()
E701: finally: cleanup()
E701: if foo == ‘blah’: one(); two(); three()</p>
<p>E702: do_one(); do_two(); do_three()</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.excluded">
<tt class="descclassname">other.pep8.</tt><tt class="descname">excluded</tt><big>(</big><em>filename</em><big>)</big><a class="headerlink" href="#other.pep8.excluded" title="Permalink to this definition">¶</a></dt>
<dd><p>Check if options.exclude contains a pattern that matches filename.</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.expand_indent">
<tt class="descclassname">other.pep8.</tt><tt class="descname">expand_indent</tt><big>(</big><em>line</em><big>)</big><a class="headerlink" href="#other.pep8.expand_indent" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the amount of indentation.
Tabs are expanded to the next multiple of 8.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">expand_indent</span><span class="p">(</span><span class="s">' '</span><span class="p">)</span>
<span class="go">4</span>
<span class="gp">>>> </span><span class="n">expand_indent</span><span class="p">(</span><span class="s">'</span><span class="se">\t</span><span class="s">'</span><span class="p">)</span>
<span class="go">8</span>
<span class="gp">>>> </span><span class="n">expand_indent</span><span class="p">(</span><span class="s">' </span><span class="se">\t</span><span class="s">'</span><span class="p">)</span>
<span class="go">8</span>
<span class="gp">>>> </span><span class="n">expand_indent</span><span class="p">(</span><span class="s">' </span><span class="se">\t</span><span class="s">'</span><span class="p">)</span>
<span class="go">8</span>
<span class="gp">>>> </span><span class="n">expand_indent</span><span class="p">(</span><span class="s">' </span><span class="se">\t</span><span class="s">'</span><span class="p">)</span>
<span class="go">16</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="other.pep8.extraneous_whitespace">
<tt class="descclassname">other.pep8.</tt><tt class="descname">extraneous_whitespace</tt><big>(</big><em>logical_line</em><big>)</big><a class="headerlink" href="#other.pep8.extraneous_whitespace" title="Permalink to this definition">¶</a></dt>
<dd><p>Avoid extraneous whitespace in the following situations:</p>
<ul class="simple">
<li>Immediately inside parentheses, brackets or braces.</li>
<li>Immediately before a comma, semicolon, or colon.</li>
</ul>
<p>Okay: spam(ham[1], {eggs: 2})
E201: spam( ham[1], {eggs: 2})
E201: spam(ham[ 1], {eggs: 2})
E201: spam(ham[1], { eggs: 2})
E202: spam(ham[1], {eggs: 2} )
E202: spam(ham[1 ], {eggs: 2})
E202: spam(ham[1], {eggs: 2 })</p>
<p>E203: if x == 4: print x, y; x, y = y , x
E203: if x == 4: print x, y ; x, y = y, x
E203: if x == 4 : print x, y; x, y = y, x</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.filename_match">
<tt class="descclassname">other.pep8.</tt><tt class="descname">filename_match</tt><big>(</big><em>filename</em><big>)</big><a class="headerlink" href="#other.pep8.filename_match" title="Permalink to this definition">¶</a></dt>
<dd><p>Check if options.filename contains a pattern that matches filename.
If options.filename is unspecified, this always returns True.</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.find_checks">
<tt class="descclassname">other.pep8.</tt><tt class="descname">find_checks</tt><big>(</big><em>argument_name</em><big>)</big><a class="headerlink" href="#other.pep8.find_checks" title="Permalink to this definition">¶</a></dt>
<dd><p>Find all globally visible functions where the first argument name
starts with argument_name.</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.get_count">
<tt class="descclassname">other.pep8.</tt><tt class="descname">get_count</tt><big>(</big><em>prefix=''</em><big>)</big><a class="headerlink" href="#other.pep8.get_count" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the total count of errors and warnings.</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.get_error_statistics">
<tt class="descclassname">other.pep8.</tt><tt class="descname">get_error_statistics</tt><big>(</big><big>)</big><a class="headerlink" href="#other.pep8.get_error_statistics" title="Permalink to this definition">¶</a></dt>
<dd><p>Get error statistics.</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.get_statistics">
<tt class="descclassname">other.pep8.</tt><tt class="descname">get_statistics</tt><big>(</big><em>prefix=''</em><big>)</big><a class="headerlink" href="#other.pep8.get_statistics" title="Permalink to this definition">¶</a></dt>
<dd><p>Get statistics for message codes that start with the prefix.</p>
<p>prefix=’’ matches all errors and warnings
prefix=’E’ matches all errors
prefix=’W’ matches all warnings
prefix=’E4’ matches all errors that have to do with imports</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.get_warning_statistics">
<tt class="descclassname">other.pep8.</tt><tt class="descname">get_warning_statistics</tt><big>(</big><big>)</big><a class="headerlink" href="#other.pep8.get_warning_statistics" title="Permalink to this definition">¶</a></dt>
<dd><p>Get warning statistics.</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.ignore_code">
<tt class="descclassname">other.pep8.</tt><tt class="descname">ignore_code</tt><big>(</big><em>code</em><big>)</big><a class="headerlink" href="#other.pep8.ignore_code" title="Permalink to this definition">¶</a></dt>
<dd><p>Check if options.ignore contains a prefix of the error code.
If options.select contains a prefix of the error code, do not ignore it.</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.imports_on_separate_lines">
<tt class="descclassname">other.pep8.</tt><tt class="descname">imports_on_separate_lines</tt><big>(</big><em>logical_line</em><big>)</big><a class="headerlink" href="#other.pep8.imports_on_separate_lines" title="Permalink to this definition">¶</a></dt>
<dd><p>Imports should usually be on separate lines.</p>
<p>Okay: import osnimport sys
E401: import sys, os</p>
<p>Okay: from subprocess import Popen, PIPE
Okay: from myclas import MyClass
Okay: from foo.bar.yourclass import YourClass
Okay: import myclass
Okay: import foo.bar.yourclass</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.indentation">
<tt class="descclassname">other.pep8.</tt><tt class="descname">indentation</tt><big>(</big><em>logical_line</em>, <em>previous_logical</em>, <em>indent_char</em>, <em>indent_level</em>, <em>previous_indent_level</em><big>)</big><a class="headerlink" href="#other.pep8.indentation" title="Permalink to this definition">¶</a></dt>
<dd><p>Use 4 spaces per indentation level.</p>
<p>For really old code that you don’t want to mess up, you can continue to
use 8-space tabs.</p>
<p>Okay: a = 1
Okay: if a == 0:n a = 1
E111: a = 1</p>
<p>Okay: for item in items:n pass
E112: for item in items:npass</p>
<p>Okay: a = 1nb = 2
E113: a = 1n b = 2</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.input_dir">
<tt class="descclassname">other.pep8.</tt><tt class="descname">input_dir</tt><big>(</big><em>dirname</em><big>)</big><a class="headerlink" href="#other.pep8.input_dir" title="Permalink to this definition">¶</a></dt>
<dd><p>Check all Python source files in this directory and all subdirectories.</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.input_file">
<tt class="descclassname">other.pep8.</tt><tt class="descname">input_file</tt><big>(</big><em>filename</em><big>)</big><a class="headerlink" href="#other.pep8.input_file" title="Permalink to this definition">¶</a></dt>
<dd><p>Run all checks on a Python source file.</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.iskeyword">
<tt class="descclassname">other.pep8.</tt><tt class="descname">iskeyword</tt><big>(</big><big>)</big><a class="headerlink" href="#other.pep8.iskeyword" title="Permalink to this definition">¶</a></dt>
<dd><p>x.__contains__(y) <==> y in x.</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.maximum_line_length">
<tt class="descclassname">other.pep8.</tt><tt class="descname">maximum_line_length</tt><big>(</big><em>physical_line</em><big>)</big><a class="headerlink" href="#other.pep8.maximum_line_length" title="Permalink to this definition">¶</a></dt>
<dd><p>Limit all lines to a maximum of 79 characters.</p>
<p>There are still many devices around that are limited to 80 character
lines; plus, limiting windows to 80 characters makes it possible to have
several windows side-by-side. The default wrapping on such devices looks
ugly. Therefore, please limit all lines to a maximum of 79 characters.
For flowing long blocks of text (docstrings or comments), limiting the
length to 72 characters is recommended.</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.message">
<tt class="descclassname">other.pep8.</tt><tt class="descname">message</tt><big>(</big><em>text</em><big>)</big><a class="headerlink" href="#other.pep8.message" title="Permalink to this definition">¶</a></dt>
<dd><p>Print a message.</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.missing_newline">
<tt class="descclassname">other.pep8.</tt><tt class="descname">missing_newline</tt><big>(</big><em>physical_line</em><big>)</big><a class="headerlink" href="#other.pep8.missing_newline" title="Permalink to this definition">¶</a></dt>
<dd><p>JCR: The last line should have a newline.</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.missing_whitespace">
<tt class="descclassname">other.pep8.</tt><tt class="descname">missing_whitespace</tt><big>(</big><em>logical_line</em><big>)</big><a class="headerlink" href="#other.pep8.missing_whitespace" title="Permalink to this definition">¶</a></dt>
<dd><p>JCR: Each comma, semicolon or colon should be followed by whitespace.</p>
<p>Okay: [a, b]
Okay: (3,)
Okay: a[1:4]
Okay: a[:4]
Okay: a[1:]
Okay: a[1:4:2]
E231: [‘a’,’b’]
E231: foo(bar,baz)</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.missing_whitespace_around_operator">
<tt class="descclassname">other.pep8.</tt><tt class="descname">missing_whitespace_around_operator</tt><big>(</big><em>logical_line</em>, <em>tokens</em><big>)</big><a class="headerlink" href="#other.pep8.missing_whitespace_around_operator" title="Permalink to this definition">¶</a></dt>
<dd><ul class="simple">
<li>Always surround these binary operators with a single space on
either side: assignment (=), augmented assignment (+=, -= etc.),
comparisons (==, <, >, !=, <>, <=, >=, in, not in, is, is not),
Booleans (and, or, not).</li>
<li>Use spaces around arithmetic operators.</li>
</ul>
<p>Okay: i = i + 1
Okay: submitted += 1
Okay: x = x * 2 - 1
Okay: hypot2 = x * x + y * y
Okay: c = (a + b) * (a - b)
Okay: foo(bar, key=’word’, <a href="#id1"><span class="problematic" id="id2">*</span></a>args, <a href="#id3"><span class="problematic" id="id4">**</span></a>kwargs)
Okay: baz(<a href="#id5"><span class="problematic" id="id6">**</span></a>kwargs)
Okay: negative = -1
Okay: spam(-1)
Okay: alpha[:-i]
Okay: if not -5 < x < +5:n pass
Okay: lambda <a href="#id7"><span class="problematic" id="id8">*</span></a>args, <a href="#id9"><span class="problematic" id="id10">**</span></a>kw: (args, kw)</p>
<p>E225: i=i+1
E225: submitted +=1
E225: x = x*2 - 1
E225: hypot2 = x*x + y*y
E225: c = (a+b) * (a-b)
E225: c = alpha -4
E225: z = x <a href="#id11"><span class="problematic" id="id12">**</span></a>y</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.mute_string">
<tt class="descclassname">other.pep8.</tt><tt class="descname">mute_string</tt><big>(</big><em>text</em><big>)</big><a class="headerlink" href="#other.pep8.mute_string" title="Permalink to this definition">¶</a></dt>
<dd><p>Replace contents with ‘xxx’ to prevent syntax matching.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">mute_string</span><span class="p">(</span><span class="s">'"abc"'</span><span class="p">)</span>
<span class="go">'"xxx"'</span>
<span class="gp">>>> </span><span class="n">mute_string</span><span class="p">(</span><span class="s">"'''abc'''"</span><span class="p">)</span>
<span class="go">"'''xxx'''"</span>
<span class="gp">>>> </span><span class="n">mute_string</span><span class="p">(</span><span class="s">"r'abc'"</span><span class="p">)</span>
<span class="go">"r'xxx'"</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="other.pep8.print_benchmark">
<tt class="descclassname">other.pep8.</tt><tt class="descname">print_benchmark</tt><big>(</big><em>elapsed</em><big>)</big><a class="headerlink" href="#other.pep8.print_benchmark" title="Permalink to this definition">¶</a></dt>
<dd><p>Print benchmark numbers.</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.print_statistics">
<tt class="descclassname">other.pep8.</tt><tt class="descname">print_statistics</tt><big>(</big><em>prefix=''</em><big>)</big><a class="headerlink" href="#other.pep8.print_statistics" title="Permalink to this definition">¶</a></dt>
<dd><p>Print overall statistics (number of errors and warnings).</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.process_options">
<tt class="descclassname">other.pep8.</tt><tt class="descname">process_options</tt><big>(</big><em>arglist=None</em><big>)</big><a class="headerlink" href="#other.pep8.process_options" title="Permalink to this definition">¶</a></dt>
<dd><p>Process options passed either via arglist or via command line args.</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.python_3000_backticks">
<tt class="descclassname">other.pep8.</tt><tt class="descname">python_3000_backticks</tt><big>(</big><em>logical_line</em><big>)</big><a class="headerlink" href="#other.pep8.python_3000_backticks" title="Permalink to this definition">¶</a></dt>
<dd><p>Backticks are removed in Python 3000.
Use repr() instead.</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.python_3000_has_key">
<tt class="descclassname">other.pep8.</tt><tt class="descname">python_3000_has_key</tt><big>(</big><em>logical_line</em><big>)</big><a class="headerlink" href="#other.pep8.python_3000_has_key" title="Permalink to this definition">¶</a></dt>
<dd><p>The {}.has_key() method will be removed in the future version of
Python. Use the ‘in’ operation instead, like:
d = {“a”: 1, “b”: 2}
if “b” in d:</p>
<blockquote>
<div>print d[“b”]</div></blockquote>
</dd></dl>
<dl class="function">
<dt id="other.pep8.python_3000_not_equal">
<tt class="descclassname">other.pep8.</tt><tt class="descname">python_3000_not_equal</tt><big>(</big><em>logical_line</em><big>)</big><a class="headerlink" href="#other.pep8.python_3000_not_equal" title="Permalink to this definition">¶</a></dt>
<dd><p>!= can also be written <>, but this is an obsolete usage kept for
backwards compatibility only. New code should always use !=.
The older syntax is removed in Python 3000.</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.python_3000_raise_comma">
<tt class="descclassname">other.pep8.</tt><tt class="descname">python_3000_raise_comma</tt><big>(</big><em>logical_line</em><big>)</big><a class="headerlink" href="#other.pep8.python_3000_raise_comma" title="Permalink to this definition">¶</a></dt>
<dd><p>When raising an exception, use “raise ValueError(‘message’)”
instead of the older form “raise ValueError, ‘message’”.</p>
<p>The paren-using form is preferred because when the exception arguments
are long or include string formatting, you don’t need to use line
continuation characters thanks to the containing parentheses. The older
form will be removed in Python 3000.</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.selftest">
<tt class="descclassname">other.pep8.</tt><tt class="descname">selftest</tt><big>(</big><big>)</big><a class="headerlink" href="#other.pep8.selftest" title="Permalink to this definition">¶</a></dt>
<dd><p>Test all check functions with test cases in docstrings.</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.tabs_obsolete">
<tt class="descclassname">other.pep8.</tt><tt class="descname">tabs_obsolete</tt><big>(</big><em>physical_line</em><big>)</big><a class="headerlink" href="#other.pep8.tabs_obsolete" title="Permalink to this definition">¶</a></dt>
<dd><p>For new projects, spaces-only are strongly recommended over tabs. Most
editors have features that make this easy to do.</p>
<p>Okay: if True:n return
W191: if True:ntreturn</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.tabs_or_spaces">
<tt class="descclassname">other.pep8.</tt><tt class="descname">tabs_or_spaces</tt><big>(</big><em>physical_line</em>, <em>indent_char</em><big>)</big><a class="headerlink" href="#other.pep8.tabs_or_spaces" title="Permalink to this definition">¶</a></dt>
<dd><p>Never mix tabs and spaces.</p>
<p>The most popular way of indenting Python is with spaces only. The
second-most popular way is with tabs only. Code indented with a mixture
of tabs and spaces should be converted to using spaces exclusively. When
invoking the Python command line interpreter with the -t option, it issues
warnings about code that illegally mixes tabs and spaces. When using -tt
these warnings become errors. These options are highly recommended!</p>
<p>Okay: if a == 0:n a = 1n b = 1
E101: if a == 0:n a = 1ntb = 1</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.trailing_blank_lines">
<tt class="descclassname">other.pep8.</tt><tt class="descname">trailing_blank_lines</tt><big>(</big><em>physical_line</em>, <em>lines</em>, <em>line_number</em><big>)</big><a class="headerlink" href="#other.pep8.trailing_blank_lines" title="Permalink to this definition">¶</a></dt>
<dd><p>JCR: Trailing blank lines are superfluous.</p>
<p>Okay: spam(1)
W391: spam(1)n</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.trailing_whitespace">
<tt class="descclassname">other.pep8.</tt><tt class="descname">trailing_whitespace</tt><big>(</big><em>physical_line</em><big>)</big><a class="headerlink" href="#other.pep8.trailing_whitespace" title="Permalink to this definition">¶</a></dt>
<dd><p>JCR: Trailing whitespace is superfluous.</p>
<p>Okay: spam(1)
W291: spam(1)s</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.whitespace_around_comma">
<tt class="descclassname">other.pep8.</tt><tt class="descname">whitespace_around_comma</tt><big>(</big><em>logical_line</em><big>)</big><a class="headerlink" href="#other.pep8.whitespace_around_comma" title="Permalink to this definition">¶</a></dt>
<dd><p>Avoid extraneous whitespace in the following situations:</p>
<ul class="simple">
<li>More than one space around an assignment (or other) operator to
align it with another.</li>
</ul>
<p>JCR: This should also be applied around comma etc.
Note: these checks are disabled by default</p>
<p>Okay: a = (1, 2)
E241: a = (1, 2)
E242: a = (1, 2)</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.whitespace_around_named_parameter_equals">
<tt class="descclassname">other.pep8.</tt><tt class="descname">whitespace_around_named_parameter_equals</tt><big>(</big><em>logical_line</em><big>)</big><a class="headerlink" href="#other.pep8.whitespace_around_named_parameter_equals" title="Permalink to this definition">¶</a></dt>
<dd><p>Don’t use spaces around the ‘=’ sign when used to indicate a
keyword argument or a default parameter value.</p>
<p>Okay: def complex(real, imag=0.0):
Okay: return magic(r=real, i=imag)
Okay: boolean(a == b)
Okay: boolean(a != b)
Okay: boolean(a <= b)
Okay: boolean(a >= b)</p>
<p>E251: def complex(real, imag = 0.0):
E251: return magic(r = real, i = imag)</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.whitespace_around_operator">
<tt class="descclassname">other.pep8.</tt><tt class="descname">whitespace_around_operator</tt><big>(</big><em>logical_line</em><big>)</big><a class="headerlink" href="#other.pep8.whitespace_around_operator" title="Permalink to this definition">¶</a></dt>
<dd><p>Avoid extraneous whitespace in the following situations:</p>
<ul class="simple">
<li>More than one space around an assignment (or other) operator to
align it with another.</li>
</ul>
<p>Okay: a = 12 + 3
E221: a = 4 + 5
E222: a = 4 + 5
E223: a = 4 + 5
E224: a = 4 + 5</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.whitespace_before_inline_comment">
<tt class="descclassname">other.pep8.</tt><tt class="descname">whitespace_before_inline_comment</tt><big>(</big><em>logical_line</em>, <em>tokens</em><big>)</big><a class="headerlink" href="#other.pep8.whitespace_before_inline_comment" title="Permalink to this definition">¶</a></dt>
<dd><p>Separate inline comments by at least two spaces.</p>
<p>An inline comment is a comment on the same line as a statement. Inline
comments should be separated by at least two spaces from the statement.
They should start with a # and a single space.</p>
<p>Okay: x = x + 1 # Increment x
Okay: x = x + 1 # Increment x
E261: x = x + 1 # Increment x
E262: x = x + 1 #Increment x
E262: x = x + 1 # Increment x</p>
</dd></dl>
<dl class="function">
<dt id="other.pep8.whitespace_before_parameters">
<tt class="descclassname">other.pep8.</tt><tt class="descname">whitespace_before_parameters</tt><big>(</big><em>logical_line</em>, <em>tokens</em><big>)</big><a class="headerlink" href="#other.pep8.whitespace_before_parameters" title="Permalink to this definition">¶</a></dt>
<dd><p>Avoid extraneous whitespace in the following situations:</p>
<ul class="simple">
<li>Immediately before the open parenthesis that starts the argument
list of a function call.</li>
<li>Immediately before the open parenthesis that starts an indexing or
slicing.</li>
</ul>
<p>Okay: spam(1)
E211: spam (1)</p>
<p>Okay: dict[‘key’] = list[index]
E211: dict [‘key’] = list[index]
E211: dict[‘key’] = list [index]</p>
</dd></dl>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="other.findsystem.html"
title="previous chapter">findsystem</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="other.pil_1_1_6.html"
title="next chapter">pil_1_1_6</a></p>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="other.pil_1_1_6.html" title="pil_1_1_6"
>next</a> |</li>
<li class="right" >
<a href="other.findsystem.html" title="findsystem"
>previous</a> |</li>
<li><a href="index.html">Phatch 0.2 documentation</a> »</li>
<li><a href="other.html" >other</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2009, www.stani.be.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
</div>
</body>
</html>
|