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 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831
|
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Frequently Asked Questions (FAQ) — Python-Future documentation</title>
<link rel="stylesheet" href="_static/basic.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/my-styles.css" type="text/css" />
<link rel="stylesheet" href="_static/bootswatch-3.3.4/cerulean/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="_static/bootstrap-sphinx.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '',
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>
<script type="text/javascript" src="_static/js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="_static/js/jquery-fix.js"></script>
<script type="text/javascript" src="_static/bootstrap-3.3.4/js/bootstrap.min.js"></script>
<script type="text/javascript" src="_static/bootstrap-sphinx.js"></script>
<link rel="shortcut icon" href="_static/python-future-icon-32.ico"/>
<link rel="top" title="Python-Future documentation" href="index.html" />
<link rel="next" title="Standard library incompatibilities" href="stdlib_incompatibilities.html" />
<link rel="prev" title="Automatic conversion to Py2/3" href="automatic_conversion.html" />
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
<meta name="apple-mobile-web-app-capable" content="yes">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-19344199-2']);
_gaq.push(['_trackPageview']);
</script>
</head>
<body role="document">
<a href="https://github.com/PythonCharmers/python-future"><img style="position: absolute; top: 45px; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png" alt="Fork me on GitHub"></a>
<div id="navbar" class="navbar navbar-inverse navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="logo"> <img height="32" width="32" src="_static/python-future-logo-textless-transparent.png" /></a>
<a class="navbar-brand" href="index.html">Python-Future</a>
<span class="navbar-text navbar-version pull-left"><b></b></span>
</div>
<div class="collapse navbar-collapse nav-collapse">
<ul class="nav navbar-nav">
<li class="divider-vertical"></li>
<li><a href="overview.html">Overview</a></li>
<li><a href="compatible_idioms.html">Cheat Sheet</a></li>
<li><a href="#">FAQ</a></li>
<li class="dropdown globaltoc-container">
<a role="button"
id="dLabelGlobalToc"
data-toggle="dropdown"
data-target="#"
href="index.html">Contents <b class="caret"></b></a>
<ul class="dropdown-menu globaltoc"
role="menu"
aria-labelledby="dLabelGlobalToc"><ul class="current">
<li class="toctree-l1"><a class="reference internal" href="whatsnew.html">What’s New</a><ul>
<li class="toctree-l2"><a class="reference internal" href="whatsnew.html#what-s-new-in-version-0-15-0-2015-07-25">What’s new in version 0.15.0 (2015-07-25)</a></li>
<li class="toctree-l2"><a class="reference internal" href="whatsnew.html#what-s-new-in-version-0-14-3-2014-12-15">What’s new in version 0.14.3 (2014-12-15)</a></li>
<li class="toctree-l2"><a class="reference internal" href="whatsnew.html#what-s-new-in-version-0-14-2-2014-11-21">What’s new in version 0.14.2 (2014-11-21)</a></li>
<li class="toctree-l2"><a class="reference internal" href="whatsnew.html#what-s-new-in-version-0-14-1-2014-10-02">What’s new in version 0.14.1 (2014-10-02)</a></li>
<li class="toctree-l2"><a class="reference internal" href="whatsnew.html#what-s-new-in-version-0-14-2014-10-02">What’s new in version 0.14 (2014-10-02)</a><ul>
<li class="toctree-l3"><a class="reference internal" href="whatsnew.html#bug-fixes">Bug fixes</a></li>
<li class="toctree-l3"><a class="reference internal" href="whatsnew.html#internal-cleanups">Internal cleanups</a></li>
<li class="toctree-l3"><a class="reference internal" href="whatsnew.html#deprecations">Deprecations</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="whatsnew.html#previous-versions">Previous versions</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="overview.html">Overview: Easy, clean, reliable Python 2/3 compatibility</a><ul>
<li class="toctree-l2"><a class="reference internal" href="overview.html#features">Features</a></li>
<li class="toctree-l2"><a class="reference internal" href="overview.html#code-examples">Code examples</a></li>
<li class="toctree-l2"><a class="reference internal" href="overview.html#automatic-conversion-to-py2-3-compatible-code">Automatic conversion to Py2/3-compatible code</a><ul>
<li class="toctree-l3"><a class="reference internal" href="overview.html#futurize-2-to-both">Futurize: 2 to both</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="overview.html#automatic-translation">Automatic translation</a></li>
<li class="toctree-l2"><a class="reference internal" href="overview.html#licensing">Licensing</a></li>
<li class="toctree-l2"><a class="reference internal" href="overview.html#next-steps">Next steps</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="quickstart.html">Quick-start guide</a><ul>
<li class="toctree-l2"><a class="reference internal" href="quickstart.html#installation">Installation</a></li>
<li class="toctree-l2"><a class="reference internal" href="quickstart.html#if-you-are-writing-code-from-scratch">If you are writing code from scratch</a></li>
<li class="toctree-l2"><a class="reference internal" href="quickstart.html#to-convert-existing-python-3-code">To convert existing Python 3 code</a></li>
<li class="toctree-l2"><a class="reference internal" href="quickstart.html#to-convert-existing-python-2-code">To convert existing Python 2 code</a></li>
<li class="toctree-l2"><a class="reference internal" href="quickstart.html#standard-library-reorganization">Standard library reorganization</a></li>
<li class="toctree-l2"><a class="reference internal" href="quickstart.html#python-2-only-dependencies">Python 2-only dependencies</a></li>
<li class="toctree-l2"><a class="reference internal" href="quickstart.html#next-steps">Next steps</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="compatible_idioms.html">Cheat Sheet: Writing Python 2-3 compatible code</a><ul>
<li class="toctree-l2"><a class="reference internal" href="compatible_idioms.html#setup">Setup</a></li>
<li class="toctree-l2"><a class="reference internal" href="compatible_idioms.html#essential-syntax-differences">Essential syntax differences</a><ul>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#print">print</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#raising-exceptions">Raising exceptions</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#catching-exceptions">Catching exceptions</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#division">Division</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#long-integers">Long integers</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#octal-constants">Octal constants</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#backtick-repr">Backtick repr</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#metaclasses">Metaclasses</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="compatible_idioms.html#strings-and-bytes">Strings and bytes</a><ul>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#unicode-text-string-literals">Unicode (text) string literals</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#byte-string-literals">Byte-string literals</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#basestring">basestring</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#unicode">unicode</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#stringio">StringIO</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="compatible_idioms.html#imports-relative-to-a-package">Imports relative to a package</a></li>
<li class="toctree-l2"><a class="reference internal" href="compatible_idioms.html#dictionaries">Dictionaries</a><ul>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#iterating-through-dict-keys-values-items">Iterating through <code class="docutils literal"><span class="pre">dict</span></code> keys/values/items</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#dict-keys-values-items-as-a-list">dict keys/values/items as a list</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="compatible_idioms.html#custom-class-behaviour">Custom class behaviour</a><ul>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#custom-iterators">Custom iterators</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#custom-str-methods">Custom <code class="docutils literal"><span class="pre">__str__</span></code> methods</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#custom-nonzero-vs-bool-method">Custom <code class="docutils literal"><span class="pre">__nonzero__</span></code> vs <code class="docutils literal"><span class="pre">__bool__</span></code> method:</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="compatible_idioms.html#lists-versus-iterators">Lists versus iterators</a><ul>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#xrange">xrange</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#range">range</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#map">map</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#imap">imap</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#zip-izip">zip, izip</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#filter-ifilter">filter, ifilter</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="compatible_idioms.html#other-builtins">Other builtins</a><ul>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#file-io-with-open">File IO with open()</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#reduce">reduce()</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#raw-input">raw_input()</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#input">input()</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#file">file()</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#execfile">execfile()</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#unichr">unichr()</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#intern">intern()</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#apply">apply()</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#chr">chr()</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#cmp">cmp()</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#reload">reload()</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="compatible_idioms.html#standard-library">Standard library</a><ul>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#dbm-modules">dbm modules</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#commands-subprocess-modules">commands / subprocess modules</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#subprocess-check-output">subprocess.check_output()</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#collections-counter-and-ordereddict">collections: Counter and OrderedDict</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#stringio-module">StringIO module</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#http-module">http module</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#xmlrpc-module">xmlrpc module</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#html-escaping-and-entities">html escaping and entities</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#html-parsing">html parsing</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#urllib-module">urllib module</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#tkinter">Tkinter</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#socketserver">socketserver</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#copy-reg-copyreg">copy_reg, copyreg</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#configparser">configparser</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#queue">queue</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#repr-reprlib">repr, reprlib</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#userdict-userlist-userstring">UserDict, UserList, UserString</a></li>
<li class="toctree-l3"><a class="reference internal" href="compatible_idioms.html#itertools-filterfalse-zip-longest">itertools: filterfalse, zip_longest</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="imports.html">Imports</a><ul>
<li class="toctree-l2"><a class="reference internal" href="imports.html#future-imports">__future__ imports</a></li>
<li class="toctree-l2"><a class="reference internal" href="imports.html#imports-of-builtins">Imports of builtins</a><ul>
<li class="toctree-l3"><a class="reference internal" href="imports.html#implicit-imports">Implicit imports</a></li>
<li class="toctree-l3"><a class="reference internal" href="imports.html#explicit-imports">Explicit imports</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="imports.html#standard-library-imports">Standard library imports</a><ul>
<li class="toctree-l3"><a class="reference internal" href="imports.html#direct-imports">Direct imports</a></li>
<li class="toctree-l3"><a class="reference internal" href="imports.html#aliased-imports">Aliased imports</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="imports.html#external-standard-library-backports">External standard-library backports</a></li>
<li class="toctree-l2"><a class="reference internal" href="imports.html#included-full-backports">Included full backports</a></li>
<li class="toctree-l2"><a class="reference internal" href="imports.html#using-python-2-only-dependencies-on-python-3">Using Python 2-only dependencies on Python 3</a></li>
<li class="toctree-l2"><a class="reference internal" href="imports.html#should-i-import-unicode-literals">Should I import unicode_literals?</a><ul>
<li class="toctree-l3"><a class="reference internal" href="imports.html#benefits">Benefits</a></li>
<li class="toctree-l3"><a class="reference internal" href="imports.html#drawbacks">Drawbacks</a></li>
<li class="toctree-l3"><a class="reference internal" href="imports.html#others-perspectives">Others’ perspectives</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="imports.html#next-steps">Next steps</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="what_else.html">What else you need to know</a><ul>
<li class="toctree-l2"><a class="reference internal" href="what_else.html#bytes">bytes</a></li>
<li class="toctree-l2"><a class="reference internal" href="what_else.html#str">str</a></li>
<li class="toctree-l2"><a class="reference internal" href="what_else.html#dict">dict</a><ul>
<li class="toctree-l3"><a class="reference internal" href="what_else.html#memory-efficiency-and-alternatives">Memory-efficiency and alternatives</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="what_else.html#int">int</a></li>
<li class="toctree-l2"><a class="reference internal" href="what_else.html#isinstance">isinstance</a></li>
<li class="toctree-l2"><a class="reference internal" href="what_else.html#passing-data-to-from-python-2-libraries">Passing data to/from Python 2 libraries</a></li>
<li class="toctree-l2"><a class="reference internal" href="what_else.html#native-string-type">Native string type</a></li>
<li class="toctree-l2"><a class="reference internal" href="what_else.html#open">open()</a></li>
<li class="toctree-l2"><a class="reference internal" href="what_else.html#custom-str-methods">Custom __str__ methods</a></li>
<li class="toctree-l2"><a class="reference internal" href="what_else.html#custom-iterators">Custom iterators</a></li>
<li class="toctree-l2"><a class="reference internal" href="what_else.html#binding-a-method-to-a-class">Binding a method to a class</a></li>
<li class="toctree-l2"><a class="reference internal" href="what_else.html#metaclasses">Metaclasses</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="automatic_conversion.html">Automatic conversion to Py2/3</a><ul>
<li class="toctree-l2"><a class="reference internal" href="automatic_conversion.html#futurize-py2-to-py2-3"><code class="docutils literal"><span class="pre">futurize</span></code>: Py2 to Py2/3</a><ul>
<li class="toctree-l3"><a class="reference internal" href="automatic_conversion.html#stage-1-safe-fixes">Stage 1: “safe” fixes</a></li>
<li class="toctree-l3"><a class="reference internal" href="automatic_conversion.html#stage-2-py3-style-code-with-wrappers-for-py2">Stage 2: Py3-style code with wrappers for Py2</a></li>
<li class="toctree-l3"><a class="reference internal" href="automatic_conversion.html#separating-text-from-bytes">Separating text from bytes</a></li>
<li class="toctree-l3"><a class="reference internal" href="automatic_conversion.html#post-conversion">Post-conversion</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="automatic_conversion.html#futurize-quick-start-guide"><code class="docutils literal"><span class="pre">futurize</span></code> quick-start guide</a><ul>
<li class="toctree-l3"><a class="reference internal" href="automatic_conversion.html#step-0-setup">Step 0: setup</a></li>
<li class="toctree-l3"><a class="reference internal" href="automatic_conversion.html#step-1-modern-py2-code">Step 1: modern Py2 code</a></li>
<li class="toctree-l3"><a class="reference internal" href="automatic_conversion.html#step-2-working-py3-code-that-still-supports-py2">Step 2: working Py3 code that still supports Py2</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="automatic_conversion.html#pasteurize-py3-to-py2-3"><code class="docutils literal"><span class="pre">pasteurize</span></code>: Py3 to Py2/3</a></li>
<li class="toctree-l2"><a class="reference internal" href="automatic_conversion.html#known-limitations">Known limitations</a></li>
</ul>
</li>
<li class="toctree-l1 current"><a class="current reference internal" href="">Frequently Asked Questions (FAQ)</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#who-is-this-for">Who is this for?</a></li>
<li class="toctree-l2"><a class="reference internal" href="#why-upgrade-to-python-3">Why upgrade to Python 3?</a></li>
<li class="toctree-l2"><a class="reference internal" href="#porting-philosophy">Porting philosophy</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#why-write-python-3-style-code">Why write Python 3-style code?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#can-t-i-just-roll-my-own-py2-3-compatibility-layer">Can’t I just roll my own Py2/3 compatibility layer?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#what-inspired-this-project">What inspired this project?</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#maturity">Maturity</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#how-well-has-it-been-tested">How well has it been tested?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#is-the-api-stable">Is the API stable?</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#relationship-between-python-future-and-other-compatibility-tools">Relationship between python-future and other compatibility tools</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#how-does-this-relate-to-2to3">How does this relate to <code class="docutils literal"><span class="pre">2to3</span></code>?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#can-i-maintain-a-python-2-codebase-and-use-2to3-to-automatically-convert-to-python-3-in-the-setup-script">Can I maintain a Python 2 codebase and use 2to3 to automatically convert to Python 3 in the setup script?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#what-is-the-relationship-between-future-and-six">What is the relationship between <code class="docutils literal"><span class="pre">future</span></code> and <code class="docutils literal"><span class="pre">six</span></code>?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#what-is-the-relationship-between-python-future-and-python-modernize">What is the relationship between <code class="docutils literal"><span class="pre">python-future</span></code> and <code class="docutils literal"><span class="pre">python-modernize</span></code>?</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#platform-and-version-support">Platform and version support</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#which-versions-of-python-does-python-future-support">Which versions of Python does <code class="docutils literal"><span class="pre">python-future</span></code> support?</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#support">Support</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#is-there-a-mailing-list">Is there a mailing list?</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#contributing">Contributing</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#can-i-help">Can I help?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#where-is-the-repo">Where is the repo?</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="stdlib_incompatibilities.html">Standard library incompatibilities</a><ul>
<li class="toctree-l2"><a class="reference internal" href="stdlib_incompatibilities.html#array-array">array.array()</a></li>
<li class="toctree-l2"><a class="reference internal" href="stdlib_incompatibilities.html#array-array-read">array.array.read()</a></li>
<li class="toctree-l2"><a class="reference internal" href="stdlib_incompatibilities.html#base64-decodebytes-and-base64-encodebytes">base64.decodebytes() and base64.encodebytes()</a></li>
<li class="toctree-l2"><a class="reference internal" href="stdlib_incompatibilities.html#re-ascii">re.ASCII</a></li>
<li class="toctree-l2"><a class="reference internal" href="stdlib_incompatibilities.html#struct-pack">struct.pack()</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="older_interfaces.html">Older interfaces</a><ul>
<li class="toctree-l2"><a class="reference internal" href="older_interfaces.html#context-manager-for-import-hooks">Context-manager for import hooks</a></li>
<li class="toctree-l2"><a class="reference internal" href="older_interfaces.html#future-moves-interface"><code class="docutils literal"><span class="pre">future.moves</span></code> interface</a><ul>
<li class="toctree-l3"><a class="reference internal" href="older_interfaces.html#comparing-future-moves-and-six-moves">Comparing future.moves and six.moves</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="older_interfaces.html#import-and-from-import-functions"><code class="docutils literal"><span class="pre">import_</span></code> and <code class="docutils literal"><span class="pre">from_import</span></code> functions</a></li>
<li class="toctree-l2"><a class="reference internal" href="older_interfaces.html#install-hooks-call">install_hooks() call</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="changelog.html">Changes in previous versions</a><ul>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#changes-in-version-0-13-1-2014-09-23">Changes in version 0.13.1 (2014-09-23)</a></li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#changes-in-version-0-13-2014-08-13">Changes in version 0.13 (2014-08-13)</a><ul>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#deprecations">Deprecations</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#new-features">New features</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#bug-fixes">Bug fixes</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#changes-in-version-0-12-4-2014-07-18">Changes in version 0.12.4 (2014-07-18)</a></li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#changes-in-version-0-12-3-2014-06-19">Changes in version 0.12.3 (2014-06-19)</a></li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#changes-in-version-0-12-2-2014-05-25">Changes in version 0.12.2 (2014-05-25)</a></li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#changes-in-version-0-12-1-2014-05-14">Changes in version 0.12.1 (2014-05-14)</a></li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#changes-in-version-0-12-0-2014-05-06">Changes in version 0.12.0 (2014-05-06)</a><ul>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#more-robust-standard-library-import-hooks">More robust standard-library import hooks</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#newobject-base-object-defines-fallback-py2-compatible-special-methods"><code class="docutils literal"><span class="pre">newobject</span></code> base object defines fallback Py2-compatible special methods</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#past-builtins-module-improved"><code class="docutils literal"><span class="pre">past.builtins</span></code> module improved</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#surrogateescape-error-handler"><code class="docutils literal"><span class="pre">surrogateescape</span></code> error handler</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#newlist-type"><code class="docutils literal"><span class="pre">newlist</span></code> type</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#listvalues-and-listitems"><code class="docutils literal"><span class="pre">listvalues</span></code> and <code class="docutils literal"><span class="pre">listitems</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#tests">Tests</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#refactoring-of-future-standard-library-future-backports">Refactoring of <code class="docutils literal"><span class="pre">future.standard_library.*</span></code> -> <code class="docutils literal"><span class="pre">future.backports</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#backported-http-server-and-urllib-modules">Backported <code class="docutils literal"><span class="pre">http.server</span></code> and <code class="docutils literal"><span class="pre">urllib</span></code> modules</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#internal-refactoring">Internal refactoring</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#id1">Bug fixes</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#changes-in-version-0-11-4-2014-05-25">Changes in version 0.11.4 (2014-05-25)</a></li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#changes-in-version-0-11-3-2014-02-27">Changes in version 0.11.3 (2014-02-27)</a><ul>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#improved-compatibility-with-requests">Improved compatibility with <code class="docutils literal"><span class="pre">requests</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#conversion-scripts-explicitly-install-import-hooks">Conversion scripts explicitly install import hooks</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#futurize-script-no-longer-adds-unicode-literals-by-default"><code class="docutils literal"><span class="pre">futurize</span></code> script no longer adds <code class="docutils literal"><span class="pre">unicode_literals</span></code> by default</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#changes-in-version-0-11-2014-01-28">Changes in version 0.11 (2014-01-28)</a><ul>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#past-package"><code class="docutils literal"><span class="pre">past</span></code> package</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#auto-translation-of-python-2-modules-upon-import">Auto-translation of Python 2 modules upon import</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#separate-pasteurize-script">Separate <code class="docutils literal"><span class="pre">pasteurize</span></code> script</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#pow">pow()</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#input-no-longer-disabled-globally-on-py2">input() no longer disabled globally on Py2</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#deprecated-feature-auto-installation-of-standard-library-import-hooks">Deprecated feature: auto-installation of standard-library import hooks</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#internal-changes">Internal changes</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#changes-in-version-0-10-2-2014-01-11">Changes in version 0.10.2 (2014-01-11)</a><ul>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#new-context-manager-interface-to-standard-library-hooks">New context-manager interface to standard_library hooks</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#changes-in-version-0-10-0-2013-12-02">Changes in version 0.10.0 (2013-12-02)</a><ul>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#backported-dict-type">Backported <code class="docutils literal"><span class="pre">dict</span></code> type</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#utility-functions-raise-and-exec">Utility functions <code class="docutils literal"><span class="pre">raise_</span></code> and <code class="docutils literal"><span class="pre">exec_</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#bugfixes">Bugfixes</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#changes-in-version-0-9-2013-11-06">Changes in version 0.9 (2013-11-06)</a><ul>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#isinstance-checks-are-supported-natively-with-backported-types"><code class="docutils literal"><span class="pre">isinstance</span></code> checks are supported natively with backported types</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#futurize-minimal-imports-by-default"><code class="docutils literal"><span class="pre">futurize</span></code>: minimal imports by default</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#looser-type-checking-for-the-backported-str-object">Looser type-checking for the backported <code class="docutils literal"><span class="pre">str</span></code> object</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#suspend-hooks-context-manager-added-to-future-standard-library">suspend_hooks() context manager added to <code class="docutils literal"><span class="pre">future.standard_library</span></code></a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#changes-in-version-0-8-2013-10-28">Changes in version 0.8 (2013-10-28)</a><ul>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#python-2-6-support">Python 2.6 support</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#unused-modules-removed">Unused modules removed</a></li>
<li class="toctree-l3"><a class="reference internal" href="changelog.html#isinstance-added-to-future-builtins-v0-8-2">isinstance() added to <code class="docutils literal"><span class="pre">future.builtins</span></code> (v0.8.2)</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="changelog.html#summary-of-all-changes">Summary of all changes</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="credits.html">Licensing and credits</a><ul>
<li class="toctree-l2"><a class="reference internal" href="credits.html#licence">Licence</a></li>
<li class="toctree-l2"><a class="reference internal" href="credits.html#sponsor">Sponsor</a></li>
<li class="toctree-l2"><a class="reference internal" href="credits.html#authors">Authors</a><ul>
<li class="toctree-l3"><a class="reference internal" href="credits.html#development-lead">Development Lead</a></li>
<li class="toctree-l3"><a class="reference internal" href="credits.html#patches">Patches</a></li>
<li class="toctree-l3"><a class="reference internal" href="credits.html#suggestions-and-feedback">Suggestions and Feedback</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="credits.html#other-credits">Other Credits</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="reference.html">API Reference (in progress)</a><ul>
<li class="toctree-l2"><a class="reference internal" href="reference.html#module-future.builtins">future.builtins Interface</a></li>
<li class="toctree-l2"><a class="reference internal" href="reference.html#module-future.types">Backported types from Python 3</a><ul>
<li class="toctree-l3"><a class="reference internal" href="reference.html#for-more-information">For more information:</a></li>
<li class="toctree-l3"><a class="reference internal" href="reference.html#range">range()</a></li>
<li class="toctree-l3"><a class="reference internal" href="reference.html#super">super()</a></li>
<li class="toctree-l3"><a class="reference internal" href="reference.html#round">round()</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="reference.html#module-future.standard_library">future.standard_library Interface</a><ul>
<li class="toctree-l3"><a class="reference internal" href="reference.html#limitations">Limitations</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="reference.html#module-future.utils">future.utils Interface</a></li>
<li class="toctree-l2"><a class="reference internal" href="reference.html#module-past.builtins">past.builtins Interface</a></li>
<li class="toctree-l2"><a class="reference internal" href="reference.html#module-past.types">Forward-ported types from Python 2</a></li>
</ul>
</li>
</ul>
</ul>
</li>
<li class="dropdown">
<a role="button"
id="dLabelLocalToc"
data-toggle="dropdown"
data-target="#"
href="#">Page <b class="caret"></b></a>
<ul class="dropdown-menu localtoc"
role="menu"
aria-labelledby="dLabelLocalToc"><ul>
<li><a class="reference internal" href="#">Frequently Asked Questions (FAQ)</a><ul>
<li><a class="reference internal" href="#who-is-this-for">Who is this for?</a></li>
<li><a class="reference internal" href="#why-upgrade-to-python-3">Why upgrade to Python 3?</a></li>
<li><a class="reference internal" href="#porting-philosophy">Porting philosophy</a><ul>
<li><a class="reference internal" href="#why-write-python-3-style-code">Why write Python 3-style code?</a></li>
<li><a class="reference internal" href="#can-t-i-just-roll-my-own-py2-3-compatibility-layer">Can’t I just roll my own Py2/3 compatibility layer?</a></li>
<li><a class="reference internal" href="#what-inspired-this-project">What inspired this project?</a></li>
</ul>
</li>
<li><a class="reference internal" href="#maturity">Maturity</a><ul>
<li><a class="reference internal" href="#how-well-has-it-been-tested">How well has it been tested?</a></li>
<li><a class="reference internal" href="#is-the-api-stable">Is the API stable?</a></li>
</ul>
</li>
<li><a class="reference internal" href="#relationship-between-python-future-and-other-compatibility-tools">Relationship between python-future and other compatibility tools</a><ul>
<li><a class="reference internal" href="#how-does-this-relate-to-2to3">How does this relate to <code class="docutils literal"><span class="pre">2to3</span></code>?</a></li>
<li><a class="reference internal" href="#can-i-maintain-a-python-2-codebase-and-use-2to3-to-automatically-convert-to-python-3-in-the-setup-script">Can I maintain a Python 2 codebase and use 2to3 to automatically convert to Python 3 in the setup script?</a></li>
<li><a class="reference internal" href="#what-is-the-relationship-between-future-and-six">What is the relationship between <code class="docutils literal"><span class="pre">future</span></code> and <code class="docutils literal"><span class="pre">six</span></code>?</a></li>
<li><a class="reference internal" href="#what-is-the-relationship-between-python-future-and-python-modernize">What is the relationship between <code class="docutils literal"><span class="pre">python-future</span></code> and <code class="docutils literal"><span class="pre">python-modernize</span></code>?</a></li>
</ul>
</li>
<li><a class="reference internal" href="#platform-and-version-support">Platform and version support</a><ul>
<li><a class="reference internal" href="#which-versions-of-python-does-python-future-support">Which versions of Python does <code class="docutils literal"><span class="pre">python-future</span></code> support?</a><ul>
<li><a class="reference internal" href="#do-you-support-pypy">Do you support Pypy?</a></li>
<li><a class="reference internal" href="#do-you-support-ironpython-and-or-jython">Do you support IronPython and/or Jython?</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#support">Support</a><ul>
<li><a class="reference internal" href="#is-there-a-mailing-list">Is there a mailing list?</a></li>
</ul>
</li>
<li><a class="reference internal" href="#contributing">Contributing</a><ul>
<li><a class="reference internal" href="#can-i-help">Can I help?</a></li>
<li><a class="reference internal" href="#where-is-the-repo">Where is the repo?</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</ul>
</li>
</ul>
<form class="navbar-form navbar-right" action="search.html" method="get">
<div class="form-group">
<input type="text" name="q" class="form-control" placeholder="Search" />
</div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-3">
<div id="sidebar" class="bs-sidenav" role="complementary"><!--<h3>Python-Future</h3>
<p>-->
<h4>Easy, clean, reliable Python 2/3 compatibility</h4>
<a href="http://python-future.org">Table of Contents</a>
<!--
</p>
<h3>Other Formats</h3>
<p>
You can download the documentation in other formats as well:
</p>
<ul>
<li><a href="http://jinja.pocoo.org/docs/jinja-docs.pdf">as PDF</a>
<li><a href="http://jinja.pocoo.org/docs/jinja-docs.zip">as zipped HTML</a>
</ul>
-->
<!--<h3>Useful Links</h3>
<ul>
<li><a href="http://pypi.python.org/pypi/future">on PyPI</a></li>
<li><a href="https://github.com/PythonCharmers/python-future">on GitHub</a></li>
</ul>
--><ul class="current">
<li class="toctree-l1"><a class="reference internal" href="whatsnew.html">What’s New</a></li>
<li class="toctree-l1"><a class="reference internal" href="overview.html">Overview: Easy, clean, reliable Python 2/3 compatibility</a></li>
<li class="toctree-l1"><a class="reference internal" href="quickstart.html">Quick-start guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="compatible_idioms.html">Cheat Sheet: Writing Python 2-3 compatible code</a></li>
<li class="toctree-l1"><a class="reference internal" href="imports.html">Imports</a></li>
<li class="toctree-l1"><a class="reference internal" href="what_else.html">What else you need to know</a></li>
<li class="toctree-l1"><a class="reference internal" href="automatic_conversion.html">Automatic conversion to Py2/3</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="">Frequently Asked Questions (FAQ)</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#who-is-this-for">Who is this for?</a></li>
<li class="toctree-l2"><a class="reference internal" href="#why-upgrade-to-python-3">Why upgrade to Python 3?</a></li>
<li class="toctree-l2"><a class="reference internal" href="#porting-philosophy">Porting philosophy</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#why-write-python-3-style-code">Why write Python 3-style code?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#can-t-i-just-roll-my-own-py2-3-compatibility-layer">Can’t I just roll my own Py2/3 compatibility layer?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#what-inspired-this-project">What inspired this project?</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#maturity">Maturity</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#how-well-has-it-been-tested">How well has it been tested?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#is-the-api-stable">Is the API stable?</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#relationship-between-python-future-and-other-compatibility-tools">Relationship between python-future and other compatibility tools</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#how-does-this-relate-to-2to3">How does this relate to <code class="docutils literal"><span class="pre">2to3</span></code>?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#can-i-maintain-a-python-2-codebase-and-use-2to3-to-automatically-convert-to-python-3-in-the-setup-script">Can I maintain a Python 2 codebase and use 2to3 to automatically convert to Python 3 in the setup script?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#what-is-the-relationship-between-future-and-six">What is the relationship between <code class="docutils literal"><span class="pre">future</span></code> and <code class="docutils literal"><span class="pre">six</span></code>?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#what-is-the-relationship-between-python-future-and-python-modernize">What is the relationship between <code class="docutils literal"><span class="pre">python-future</span></code> and <code class="docutils literal"><span class="pre">python-modernize</span></code>?</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#platform-and-version-support">Platform and version support</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#which-versions-of-python-does-python-future-support">Which versions of Python does <code class="docutils literal"><span class="pre">python-future</span></code> support?</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#support">Support</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#is-there-a-mailing-list">Is there a mailing list?</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#contributing">Contributing</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#can-i-help">Can I help?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#where-is-the-repo">Where is the repo?</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="stdlib_incompatibilities.html">Standard library incompatibilities</a></li>
<li class="toctree-l1"><a class="reference internal" href="older_interfaces.html">Older interfaces</a></li>
<li class="toctree-l1"><a class="reference internal" href="changelog.html">Changes in previous versions</a></li>
<li class="toctree-l1"><a class="reference internal" href="credits.html">Licensing and credits</a></li>
<li class="toctree-l1"><a class="reference internal" href="reference.html">API Reference (in progress)</a></li>
</ul>
</div>
</div>
<div class="col-md-9">
<div class="section" id="frequently-asked-questions-faq">
<h1>Frequently Asked Questions (FAQ)<a class="headerlink" href="#frequently-asked-questions-faq" title="Permalink to this headline">¶</a></h1>
<div class="section" id="who-is-this-for">
<h2>Who is this for?<a class="headerlink" href="#who-is-this-for" title="Permalink to this headline">¶</a></h2>
<p>1. People with existing or new Python 3 codebases who wish to provide
ongoing Python 2.6 / 2.7 support easily and with little maintenance burden.</p>
<p>2. People who wish to ease and accelerate migration of their Python 2 codebases
to Python 3.3+, module by module, without giving up Python 2 compatibility.</p>
</div>
<div class="section" id="why-upgrade-to-python-3">
<h2>Why upgrade to Python 3?<a class="headerlink" href="#why-upgrade-to-python-3" title="Permalink to this headline">¶</a></h2>
<blockquote class="epigraph">
<div><p>“Python 2 is the next COBOL.”</p>
<p class="attribution">—Alex Gaynor, at PyCon AU 2013</p>
</div></blockquote>
<p>Python 2.7 is the end of the Python 2 line. (See <a class="reference external" href="http://www.python.org/peps/pep-0404/">PEP 404</a>.) The language and standard
libraries are improving only in Python 3.x.</p>
<p>Python 3.x is a better language and better set of standard libraries than
Python 2.x in many ways. Python 3.x is cleaner, less warty, and easier to
learn than Python 2. It has better memory efficiency, easier Unicode handling,
and powerful new features like the <a class="reference external" href="https://docs.python.org/3/library/asyncio.html">asyncio</a> module.</p>
</div>
<div class="section" id="porting-philosophy">
<h2>Porting philosophy<a class="headerlink" href="#porting-philosophy" title="Permalink to this headline">¶</a></h2>
<div class="section" id="why-write-python-3-style-code">
<h3>Why write Python 3-style code?<a class="headerlink" href="#why-write-python-3-style-code" title="Permalink to this headline">¶</a></h3>
<p>Here are some quotes:</p>
<ul class="simple">
<li>“Django’s developers have found that attempting to write Python 3 code
that’s compatible with Python 2 is much more rewarding than the
opposite.” from the <a class="reference external" href="https://docs.djangoproject.com/en/dev/topics/python3/">Django docs</a>.</li>
<li>“Thanks to Python 3 being more strict about things than Python 2 (e.g.,
bytes vs. strings), the source translation [from Python 3 to 2] can be
easier and more straightforward than from Python 2 to 3. Plus it gives
you more direct experience developing in Python 3 which, since it is
the future of Python, is a good thing long-term.” from the official
guide <a class="reference external" href="http://docs.python.org/2/howto/pyporting.html">“Porting Python 2 Code to Python 3”</a> by Brett Cannon.</li>
<li>“Developer energy should be reserved for addressing real technical
difficulties associated with the Python 3 transition (like
distinguishing their 8-bit text strings from their binary data). They
shouldn’t be punished with additional code changes ...” from <a class="reference external" href="http://www.python.org/dev/peps/pep-0414/">PEP 414</a> by Armin Ronacher and Nick
Coghlan.</li>
</ul>
</div>
<div class="section" id="can-t-i-just-roll-my-own-py2-3-compatibility-layer">
<h3>Can’t I just roll my own Py2/3 compatibility layer?<a class="headerlink" href="#can-t-i-just-roll-my-own-py2-3-compatibility-layer" title="Permalink to this headline">¶</a></h3>
<p>Yes, but using <code class="docutils literal"><span class="pre">python-future</span></code> will probably be easier and lead to cleaner
code with fewer bugs.</p>
<p>Consider this quote:</p>
<blockquote class="epigraph">
<div><p>“Duplication of effort is wasteful, and replacing the various
home-grown approaches with a standard feature usually ends up making
things more readable, and interoperable as well.”</p>
<p class="attribution">—Guido van Rossum (<a class="reference external" href="http://www.artima.com/weblogs/viewpost.jsp?thread=86641">blog post</a>)</p>
</div></blockquote>
<p><code class="docutils literal"><span class="pre">future</span></code> also includes various Py2/3 compatibility tools in
<a class="reference internal" href="reference.html#module-future.utils" title="future.utils"><code class="xref py py-mod docutils literal"><span class="pre">future.utils</span></code></a> picked from large projects (including IPython,
Django, Jinja2, Pandas), which should reduce the burden on every project to
roll its own py3k compatibility wrapper module.</p>
</div>
<div class="section" id="what-inspired-this-project">
<h3>What inspired this project?<a class="headerlink" href="#what-inspired-this-project" title="Permalink to this headline">¶</a></h3>
<p>In our Python training courses, we at <a class="reference external" href="http://pythoncharmers.com">Python Charmers</a> faced a dilemma: teach people Python 3, which was
future-proof but not as useful to them today because of weaker 3rd-party
package support, or teach people Python 2, which was more useful today but
would require them to change their code and unlearn various habits soon. We
searched for ways to avoid polluting the world with more deprecated code, but
didn’t find a good way.</p>
<p>Also, in attempting to help with porting packages such as <a class="reference external" href="http://scikit-learn.org">scikit-learn</a> to Python 3, I (Ed) was dissatisfied with how much
code cruft was necessary to introduce to support Python 2 and 3 from a single
codebase (the preferred porting option). Since backward-compatibility with
Python 2 may be necessary for at least the next 5 years, one of the promised
benefits of Python 3 – cleaner code with fewer of Python 2’s warts – was
difficult to realize before in practice in a single codebase that supported
both platforms.</p>
<p>The goal is to accelerate the uptake of Python 3 and help the strong Python
community to remain united around a single version of the language.</p>
</div>
</div>
<div class="section" id="maturity">
<h2>Maturity<a class="headerlink" href="#maturity" title="Permalink to this headline">¶</a></h2>
<div class="section" id="how-well-has-it-been-tested">
<h3>How well has it been tested?<a class="headerlink" href="#how-well-has-it-been-tested" title="Permalink to this headline">¶</a></h3>
<p><code class="docutils literal"><span class="pre">future</span></code> is used by several major projects, including <a class="reference external" href="http://mezzanine.jupo.org">mezzanine</a> and <a class="reference external" href="http://www.obspy.org">ObsPy</a>. It is also
currently being used to help with porting 800,000 lines of Python 2 code in
<a class="reference external" href="http://sagemath.org">Sage</a> to Python 2/3.</p>
<p>Currently <code class="docutils literal"><span class="pre">python-future</span></code> has 990+ unit tests. Many of these are straight
from the Python 3.3 and 3.4 test suites.</p>
<p>In general, the <code class="docutils literal"><span class="pre">future</span></code> package itself is in good shape, whereas the
<code class="docutils literal"><span class="pre">futurize</span></code> script for automatic porting is incomplete and imperfect.
(Chances are it will require some manual cleanup afterwards.) The <code class="docutils literal"><span class="pre">past</span></code>
package also needs to be expanded.</p>
</div>
<div class="section" id="is-the-api-stable">
<h3>Is the API stable?<a class="headerlink" href="#is-the-api-stable" title="Permalink to this headline">¶</a></h3>
<p>Not yet; <code class="docutils literal"><span class="pre">future</span></code> is still in beta. Where possible, we will try not to break
anything which was documented and used to work. After version 1.0 is released,
the API will not change in backward-incompatible ways until a hypothetical
version 2.0.</p>
</div>
</div>
<div class="section" id="relationship-between-python-future-and-other-compatibility-tools">
<h2>Relationship between python-future and other compatibility tools<a class="headerlink" href="#relationship-between-python-future-and-other-compatibility-tools" title="Permalink to this headline">¶</a></h2>
<div class="section" id="how-does-this-relate-to-2to3">
<h3>How does this relate to <code class="docutils literal"><span class="pre">2to3</span></code>?<a class="headerlink" href="#how-does-this-relate-to-2to3" title="Permalink to this headline">¶</a></h3>
<p><code class="docutils literal"><span class="pre">2to3</span></code> is a powerful and flexible tool that can produce different
styles of Python 3 code. It is, however, primarily designed for one-way
porting efforts, for projects that can leave behind Python 2 support.</p>
<p>The example at the top of the <a class="reference external" href="http://docs.python.org/2/library/2to3.html">2to3 docs</a> demonstrates this. After
transformation by <code class="docutils literal"><span class="pre">2to3</span></code>, <code class="docutils literal"><span class="pre">example.py</span></code> looks like this:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">greet</span><span class="p">(</span><span class="n">name</span><span class="p">):</span>
<span class="k">print</span><span class="p">(</span><span class="s">"Hello, {0}!"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">name</span><span class="p">))</span>
<span class="k">print</span><span class="p">(</span><span class="s">"What's your name?"</span><span class="p">)</span>
<span class="n">name</span> <span class="o">=</span> <span class="nb">input</span><span class="p">()</span>
<span class="n">greet</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>
</pre></div>
</div>
<p>This is Python 3 code that, although syntactically valid on Python 2,
is semantically incorrect. On Python 2, it raises an exception for
most inputs; worse, it allows arbitrary code execution by the user
for specially crafted inputs because of the <code class="docutils literal"><span class="pre">eval()</span></code> executed by Python
2’s <code class="docutils literal"><span class="pre">input()</span></code> function.</p>
<p>This is not an isolated example; almost every output of <code class="docutils literal"><span class="pre">2to3</span></code> will need
modification to provide backward compatibility with Python 2. As an
alternative, the <code class="docutils literal"><span class="pre">python-future</span></code> project provides a script called
<code class="docutils literal"><span class="pre">futurize</span></code> that is based on <code class="docutils literal"><span class="pre">lib2to3</span></code> but will produce code that is
compatible with both platforms (Py2 and Py3).</p>
</div>
<div class="section" id="can-i-maintain-a-python-2-codebase-and-use-2to3-to-automatically-convert-to-python-3-in-the-setup-script">
<h3>Can I maintain a Python 2 codebase and use 2to3 to automatically convert to Python 3 in the setup script?<a class="headerlink" href="#can-i-maintain-a-python-2-codebase-and-use-2to3-to-automatically-convert-to-python-3-in-the-setup-script" title="Permalink to this headline">¶</a></h3>
<p>This was originally the approach recommended by Python’s core developers,
but it has some large drawbacks:</p>
<p>1. First, your actual working codebase will be stuck with Python 2’s
warts and smaller feature set for as long as you need to retain Python 2
compatibility. This may be at least 5 years for many projects, possibly
much longer.</p>
<p>2. Second, this approach carries the significant disadvantage that you
cannot apply patches submitted by Python 3 users against the
auto-generated Python 3 code. (See <a class="reference external" href="http://www.youtube.com/watch?v=xNZ4OVO2Z_E">this talk</a> by Jacob Kaplan-Moss.)</p>
</div>
<div class="section" id="what-is-the-relationship-between-future-and-six">
<h3>What is the relationship between <code class="docutils literal"><span class="pre">future</span></code> and <code class="docutils literal"><span class="pre">six</span></code>?<a class="headerlink" href="#what-is-the-relationship-between-future-and-six" title="Permalink to this headline">¶</a></h3>
<p><code class="docutils literal"><span class="pre">python-future</span></code> is a higher-level compatibility layer than <code class="docutils literal"><span class="pre">six</span></code> that
includes more backported functionality from Python 3, more forward-ported
functionality from Python 2, and supports cleaner code, but requires more
modern Python versions to run.</p>
<p><code class="docutils literal"><span class="pre">python-future</span></code> and <code class="docutils literal"><span class="pre">six</span></code> share the same goal of making it possible to write
a single-source codebase that works on both Python 2 and Python 3.
<code class="docutils literal"><span class="pre">python-future</span></code> has the further goal of allowing standard Py3 code to run with
almost no modification on both Py3 and Py2. <code class="docutils literal"><span class="pre">future</span></code> provides a more
complete set of support for Python 3’s features, including backports of
Python 3 builtins such as the <code class="docutils literal"><span class="pre">bytes</span></code> object (which is very different
to Python 2’s <code class="docutils literal"><span class="pre">str</span></code> object) and several standard library modules.</p>
<p><code class="docutils literal"><span class="pre">python-future</span></code> supports only Python 2.6+ and Python 3.3+, whereas <code class="docutils literal"><span class="pre">six</span></code>
supports all versions of Python from 2.4 onwards. (See
<a class="reference internal" href="#supported-versions"><span>Which versions of Python does python-future support?</span></a>.) If you must support older Python versions,
<code class="docutils literal"><span class="pre">six</span></code> will be esssential for you. However, beware that maintaining
single-source compatibility with older Python versions is ugly and <a class="reference external" href="http://lucumr.pocoo.org/2013/5/21/porting-to-python-3-redux/">not
fun</a>.</p>
<p>If you can drop support for older Python versions, <code class="docutils literal"><span class="pre">python-future</span></code> leverages
some important features introduced into Python 2.6 and 2.7, such as
import hooks, and a comprehensive and well-tested set of backported
functionality, to allow you to write more idiomatic, maintainable code with
fewer compatibility hacks.</p>
</div>
<div class="section" id="what-is-the-relationship-between-python-future-and-python-modernize">
<h3>What is the relationship between <code class="docutils literal"><span class="pre">python-future</span></code> and <code class="docutils literal"><span class="pre">python-modernize</span></code>?<a class="headerlink" href="#what-is-the-relationship-between-python-future-and-python-modernize" title="Permalink to this headline">¶</a></h3>
<p><code class="docutils literal"><span class="pre">python-future</span></code> contains, in addition to the <code class="docutils literal"><span class="pre">future</span></code> compatibility
package, a <code class="docutils literal"><span class="pre">futurize</span></code> script that is similar to <code class="docutils literal"><span class="pre">python-modernize.py</span></code>
in intent and design. Both are based heavily on <code class="docutils literal"><span class="pre">2to3</span></code>.</p>
<p>Whereas <code class="docutils literal"><span class="pre">python-modernize</span></code> converts Py2 code into a common subset of
Python 2 and 3, with <code class="docutils literal"><span class="pre">six</span></code> as a run-time dependency, <code class="docutils literal"><span class="pre">futurize</span></code>
converts either Py2 or Py3 code into (almost) standard Python 3 code,
with <code class="docutils literal"><span class="pre">future</span></code> as a run-time dependency.</p>
<p>Because <code class="docutils literal"><span class="pre">future</span></code> provides more backported Py3 behaviours from <code class="docutils literal"><span class="pre">six</span></code>,
the code resulting from <code class="docutils literal"><span class="pre">futurize</span></code> is more likely to work
identically on both Py3 and Py2 with less additional manual porting
effort.</p>
</div>
</div>
<div class="section" id="platform-and-version-support">
<h2>Platform and version support<a class="headerlink" href="#platform-and-version-support" title="Permalink to this headline">¶</a></h2>
<div class="section" id="which-versions-of-python-does-python-future-support">
<span id="supported-versions"></span><h3>Which versions of Python does <code class="docutils literal"><span class="pre">python-future</span></code> support?<a class="headerlink" href="#which-versions-of-python-does-python-future-support" title="Permalink to this headline">¶</a></h3>
<p>Python 2.6, 2.7, and 3.3+ only.</p>
<p>Python 2.6 and 2.7 introduced many important forward-compatibility
features (such as import hooks, <code class="docutils literal"><span class="pre">b'...'</span></code> literals and <code class="docutils literal"><span class="pre">__future__</span></code>
definitions) that greatly reduce the maintenance burden for single-source
Py2/3 compatible code. <code class="docutils literal"><span class="pre">future</span></code> leverages these features and aims to
close the remaining gap between Python 3 and 2.6 / 2.7.</p>
<p>Python 3.2 could perhaps be supported too, although the illegal unicode
literal <code class="docutils literal"><span class="pre">u'...'</span></code> syntax may be inconvenient to work around. The Py3.2
userbase is very small, however. Please let us know via GitHub <a class="reference external" href="https://github.com/PythonCharmers/python-future/issues/29">issue #29</a> if you
would like to see Py3.2 support.</p>
<div class="section" id="do-you-support-pypy">
<h4>Do you support Pypy?<a class="headerlink" href="#do-you-support-pypy" title="Permalink to this headline">¶</a></h4>
<p>Yes, except for the standard library import hooks (currently). Feedback
and pull requests are welcome!</p>
</div>
<div class="section" id="do-you-support-ironpython-and-or-jython">
<h4>Do you support IronPython and/or Jython?<a class="headerlink" href="#do-you-support-ironpython-and-or-jython" title="Permalink to this headline">¶</a></h4>
<p>Not sure. This would be nice...</p>
</div>
</div>
</div>
<div class="section" id="support">
<span id="id1"></span><h2>Support<a class="headerlink" href="#support" title="Permalink to this headline">¶</a></h2>
<div class="section" id="is-there-a-mailing-list">
<h3>Is there a mailing list?<a class="headerlink" href="#is-there-a-mailing-list" title="Permalink to this headline">¶</a></h3>
<p>Yes, please ask any questions on the <a class="reference external" href="https://mail.python.org/mailman/listinfo/python-porting">python-porting</a> mailing list.</p>
</div>
</div>
<div class="section" id="contributing">
<span id="id2"></span><h2>Contributing<a class="headerlink" href="#contributing" title="Permalink to this headline">¶</a></h2>
<div class="section" id="can-i-help">
<h3>Can I help?<a class="headerlink" href="#can-i-help" title="Permalink to this headline">¶</a></h3>
<p>Yes please :) We welcome bug reports, additional tests, pull requests,
and stories of either success or failure with using it. Help with the fixers
for the <code class="docutils literal"><span class="pre">futurize</span></code> script is particularly welcome.</p>
</div>
<div class="section" id="where-is-the-repo">
<h3>Where is the repo?<a class="headerlink" href="#where-is-the-repo" title="Permalink to this headline">¶</a></h3>
<p><a class="reference external" href="https://github.com/PythonCharmers/python-future">https://github.com/PythonCharmers/python-future</a>.</p>
</div>
</div>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<p class="pull-right">
<a href="#">Back to top</a>
</p>
<p>
© Copyright 2013-2015, Python Charmers Pty Ltd, Australia.<br/>
</p>
</div>
</footer>
<div class="footer">
<script type="text/javascript">
(function() {
var ga = document.createElement('script');
ga.src = ('https:' == document.location.protocol ?
'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
ga.setAttribute('async', 'true');
document.documentElement.firstChild.appendChild(ga);
})();
</script>
</div>
</body>
</html>
|