This file is indexed.

/usr/share/doc/python-pathlib-doc/html/index.html is in python-pathlib-doc 1.0.1-2.

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
 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
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
<!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>pathlib &mdash; pathlib 1.0.1 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:     '1.0.1',
        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="pathlib 1.0.1 documentation" href="#" /> 
  </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><a href="#">pathlib 1.0.1 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-pathlib">
<span id="pathlib"></span><h1>pathlib<a class="headerlink" href="#module-pathlib" title="Permalink to this headline"></a></h1>
<p>Manipulating filesystem paths as string objects can quickly become cumbersome:
multiple calls to <tt class="xref py py-func docutils literal"><span class="pre">os.path.join()</span></tt> or <tt class="xref py py-func docutils literal"><span class="pre">os.path.dirname()</span></tt>, etc.
This module offers a set of classes featuring all the common operations on
paths in an easy, object-oriented way.</p>
<p>This module is best used with Python 3.2 or later, but it is also compatible
with Python 2.7.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This module has been <a class="reference external" href="http://docs.python.org/dev/library/pathlib.html">included</a>
in the Python 3.4 standard library after <span class="target" id="index-0"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0428"><strong>PEP 428</strong></a> acceptance. You only
need to install it for Python 3.3 or older.</p>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><span class="target" id="index-1"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0428"><strong>PEP 428</strong></a>: Rationale for the final pathlib design and API.</p>
</div>
<div class="section" id="download">
<h2>Download<a class="headerlink" href="#download" title="Permalink to this headline"></a></h2>
<p>Standalone releases are available on PyPI: <a class="reference external" href="http://pypi.python.org/pypi/pathlib/">http://pypi.python.org/pypi/pathlib/</a></p>
<p>Main development now takes place in the Python standard library: see
the <a class="reference external" href="http://docs.python.org/devguide/">Python developer&#8217;s guide</a>.</p>
<p>The maintenance repository for this standalone backport module can be
found on BitBucket, but activity is expected to be quite low:
<a class="reference external" href="https://bitbucket.org/pitrou/pathlib/">https://bitbucket.org/pitrou/pathlib/</a></p>
</div>
<div class="section" id="high-level-view">
<h2>High-level view<a class="headerlink" href="#high-level-view" title="Permalink to this headline"></a></h2>
<p>This module offers classes representing filesystem paths with semantics
appropriate for different operating systems.  Path classes are divided
between <a class="reference internal" href="#pure-paths"><em>pure paths</em></a>, which provide purely computational
operations without I/O, and <a class="reference internal" href="#concrete-paths"><em>concrete paths</em></a>, which
inherit from pure paths but also provide I/O operations.</p>
<img alt="_images/pathlib-inheritance.png" class="align-center" src="_images/pathlib-inheritance.png" />
<p>If you&#8217;ve never used this module before or just aren&#8217;t sure which class is
right for your task, <a class="reference internal" href="#pathlib.Path" title="pathlib.Path"><tt class="xref py py-class docutils literal"><span class="pre">Path</span></tt></a> is most likely what you need. It instantiates
a <a class="reference internal" href="#concrete-paths"><em>concrete path</em></a> for the platform the code is running on.</p>
<p>Pure paths are useful in some special cases; for example:</p>
<ol class="arabic simple">
<li>If you want to manipulate Windows paths on a Unix machine (or vice versa).
You cannot instantiate a <a class="reference internal" href="#pathlib.WindowsPath" title="pathlib.WindowsPath"><tt class="xref py py-class docutils literal"><span class="pre">WindowsPath</span></tt></a> when running on Unix, but you
can instantiate <a class="reference internal" href="#pathlib.PureWindowsPath" title="pathlib.PureWindowsPath"><tt class="xref py py-class docutils literal"><span class="pre">PureWindowsPath</span></tt></a>.</li>
<li>You want to make sure that your code only manipulates paths without actually
accessing the OS. In this case, instantiating one of the pure classes may be
useful since those simply don&#8217;t have any OS-accessing operations.</li>
</ol>
</div>
<div class="section" id="basic-use">
<h2>Basic use<a class="headerlink" href="#basic-use" title="Permalink to this headline"></a></h2>
<p>Importing the module classes:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pathlib</span> <span class="kn">import</span> <span class="o">*</span>
</pre></div>
</div>
<p>Listing subdirectories:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="s">&#39;.&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="p">[</span><span class="n">x</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">p</span><span class="o">.</span><span class="n">iterdir</span><span class="p">()</span> <span class="k">if</span> <span class="n">x</span><span class="o">.</span><span class="n">is_dir</span><span class="p">()]</span>
<span class="go">[PosixPath(&#39;.hg&#39;), PosixPath(&#39;docs&#39;), PosixPath(&#39;dist&#39;),</span>
<span class="go"> PosixPath(&#39;__pycache__&#39;), PosixPath(&#39;build&#39;)]</span>
</pre></div>
</div>
<p>Listing Python source files in this directory tree:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="nb">list</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="s">&#39;**/*.py&#39;</span><span class="p">))</span>
<span class="go">[PosixPath(&#39;test_pathlib.py&#39;), PosixPath(&#39;setup.py&#39;),</span>
<span class="go"> PosixPath(&#39;pathlib.py&#39;), PosixPath(&#39;docs/conf.py&#39;),</span>
<span class="go"> PosixPath(&#39;build/lib/pathlib.py&#39;)]</span>
</pre></div>
</div>
<p>Navigating inside a directory tree:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="s">&#39;/etc&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">q</span> <span class="o">=</span> <span class="n">p</span> <span class="o">/</span> <span class="s">&#39;init.d&#39;</span> <span class="o">/</span> <span class="s">&#39;reboot&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">q</span>
<span class="go">PosixPath(&#39;/etc/init.d/reboot&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">q</span><span class="o">.</span><span class="n">resolve</span><span class="p">()</span>
<span class="go">PosixPath(&#39;/etc/rc.d/init.d/halt&#39;)</span>
</pre></div>
</div>
<p>Querying path properties:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">q</span><span class="o">.</span><span class="n">exists</span><span class="p">()</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">q</span><span class="o">.</span><span class="n">is_dir</span><span class="p">()</span>
<span class="go">False</span>
</pre></div>
</div>
<p>Opening a file:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">with</span> <span class="n">q</span><span class="o">.</span><span class="n">open</span><span class="p">()</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
<span class="gp">...</span>
<span class="go">&#39;#!/bin/bash\n&#39;</span>
</pre></div>
</div>
</div>
<div class="section" id="pure-paths">
<span id="id1"></span><h2>Pure paths<a class="headerlink" href="#pure-paths" title="Permalink to this headline"></a></h2>
<p>Pure path objects provide path-handling operations which don&#8217;t actually
access a filesystem.  There are three ways to access these classes, which
we also call <em>flavours</em>:</p>
<dl class="class">
<dt id="pathlib.PurePath">
<em class="property">class </em><tt class="descclassname">pathlib.</tt><tt class="descname">PurePath</tt><big>(</big><em>*pathsegments</em><big>)</big><a class="headerlink" href="#pathlib.PurePath" title="Permalink to this definition"></a></dt>
<dd><p>A generic class that represents the system&#8217;s path flavour (instantiating
it creates either a <a class="reference internal" href="#pathlib.PurePosixPath" title="pathlib.PurePosixPath"><tt class="xref py py-class docutils literal"><span class="pre">PurePosixPath</span></tt></a> or a <a class="reference internal" href="#pathlib.PureWindowsPath" title="pathlib.PureWindowsPath"><tt class="xref py py-class docutils literal"><span class="pre">PureWindowsPath</span></tt></a>):</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PurePath</span><span class="p">(</span><span class="s">&#39;setup.py&#39;</span><span class="p">)</span>      <span class="c"># Running on a Unix machine</span>
<span class="go">PurePosixPath(&#39;setup.py&#39;)</span>
</pre></div>
</div>
<p>Each element of <em>pathsegments</em> can be either a string or bytes object
representing a path segment; it can also be another path object:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PurePath</span><span class="p">(</span><span class="s">&#39;foo&#39;</span><span class="p">,</span> <span class="s">&#39;some/path&#39;</span><span class="p">,</span> <span class="s">&#39;bar&#39;</span><span class="p">)</span>
<span class="go">PurePosixPath(&#39;foo/some/path/bar&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PurePath</span><span class="p">(</span><span class="n">Path</span><span class="p">(</span><span class="s">&#39;foo&#39;</span><span class="p">),</span> <span class="n">Path</span><span class="p">(</span><span class="s">&#39;bar&#39;</span><span class="p">))</span>
<span class="go">PurePosixPath(&#39;foo/bar&#39;)</span>
</pre></div>
</div>
<p>When <em>pathsegments</em> is empty, the current directory is assumed:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PurePath</span><span class="p">()</span>
<span class="go">PurePosixPath(&#39;.&#39;)</span>
</pre></div>
</div>
<p>When several absolute paths are given, the last is taken as an anchor
(mimicking <tt class="xref py py-func docutils literal"><span class="pre">os.path.join()</span></tt>&#8216;s behaviour):</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PurePath</span><span class="p">(</span><span class="s">&#39;/etc&#39;</span><span class="p">,</span> <span class="s">&#39;/usr&#39;</span><span class="p">,</span> <span class="s">&#39;lib64&#39;</span><span class="p">)</span>
<span class="go">PurePosixPath(&#39;/usr/lib64&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;c:/Windows&#39;</span><span class="p">,</span> <span class="s">&#39;d:bar&#39;</span><span class="p">)</span>
<span class="go">PureWindowsPath(&#39;d:bar&#39;)</span>
</pre></div>
</div>
<p>However, in a Windows path, changing the local root doesn&#8217;t discard the
previous drive setting:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;c:/Windows&#39;</span><span class="p">,</span> <span class="s">&#39;/Program Files&#39;</span><span class="p">)</span>
<span class="go">PureWindowsPath(&#39;c:/Program Files&#39;)</span>
</pre></div>
</div>
<p>Spurious slashes and single dots are collapsed, but double dots (<tt class="docutils literal"><span class="pre">'..'</span></tt>)
are not, since this would change the meaning of a path in the face of
symbolic links:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PurePath</span><span class="p">(</span><span class="s">&#39;foo//bar&#39;</span><span class="p">)</span>
<span class="go">PurePosixPath(&#39;foo/bar&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PurePath</span><span class="p">(</span><span class="s">&#39;foo/./bar&#39;</span><span class="p">)</span>
<span class="go">PurePosixPath(&#39;foo/bar&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PurePath</span><span class="p">(</span><span class="s">&#39;foo/../bar&#39;</span><span class="p">)</span>
<span class="go">PurePosixPath(&#39;foo/../bar&#39;)</span>
</pre></div>
</div>
<p>(a naïve approach would make <tt class="docutils literal"><span class="pre">PurePosixPath('foo/../bar')</span></tt> equivalent
to <tt class="docutils literal"><span class="pre">PurePosixPath('bar')</span></tt>, which is wrong if <tt class="docutils literal"><span class="pre">foo</span></tt> is a symbolic link
to another directory)</p>
</dd></dl>

<dl class="class">
<dt id="pathlib.PurePosixPath">
<em class="property">class </em><tt class="descclassname">pathlib.</tt><tt class="descname">PurePosixPath</tt><big>(</big><em>*pathsegments</em><big>)</big><a class="headerlink" href="#pathlib.PurePosixPath" title="Permalink to this definition"></a></dt>
<dd><p>A subclass of <a class="reference internal" href="#pathlib.PurePath" title="pathlib.PurePath"><tt class="xref py py-class docutils literal"><span class="pre">PurePath</span></tt></a>, this path flavour represents non-Windows
filesystem paths:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;/etc&#39;</span><span class="p">)</span>
<span class="go">PurePosixPath(&#39;/etc&#39;)</span>
</pre></div>
</div>
<p><em>pathsegments</em> is specified similarly to <a class="reference internal" href="#pathlib.PurePath" title="pathlib.PurePath"><tt class="xref py py-class docutils literal"><span class="pre">PurePath</span></tt></a>.</p>
</dd></dl>

<dl class="class">
<dt id="pathlib.PureWindowsPath">
<em class="property">class </em><tt class="descclassname">pathlib.</tt><tt class="descname">PureWindowsPath</tt><big>(</big><em>*pathsegments</em><big>)</big><a class="headerlink" href="#pathlib.PureWindowsPath" title="Permalink to this definition"></a></dt>
<dd><p>A subclass of <a class="reference internal" href="#pathlib.PurePath" title="pathlib.PurePath"><tt class="xref py py-class docutils literal"><span class="pre">PurePath</span></tt></a>, this path flavour represents Windows
filesystem paths:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;c:/Program Files/&#39;</span><span class="p">)</span>
<span class="go">PureWindowsPath(&#39;c:/Program Files&#39;)</span>
</pre></div>
</div>
<p><em>pathsegments</em> is specified similarly to <a class="reference internal" href="#pathlib.PurePath" title="pathlib.PurePath"><tt class="xref py py-class docutils literal"><span class="pre">PurePath</span></tt></a>.</p>
</dd></dl>

<p>Regardless of the system you&#8217;re running on, you can instantiate all of
these classes, since they don&#8217;t provide any operation that does system calls.</p>
<div class="section" id="general-properties">
<h3>General properties<a class="headerlink" href="#general-properties" title="Permalink to this headline"></a></h3>
<p>Paths are immutable and hashable.  Paths of a same flavour are comparable
and orderable.  These properties respect the flavour&#8217;s case-folding
semantics:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;foo&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;FOO&#39;</span><span class="p">)</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;foo&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;FOO&#39;</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;FOO&#39;</span><span class="p">)</span> <span class="ow">in</span> <span class="p">{</span> <span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;foo&#39;</span><span class="p">)</span> <span class="p">}</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;C:&#39;</span><span class="p">)</span> <span class="o">&lt;</span> <span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;d:&#39;</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
<p>Paths of a different flavour compare unequal and cannot be ordered:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;foo&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;foo&#39;</span><span class="p">)</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;foo&#39;</span><span class="p">)</span> <span class="o">&lt;</span> <span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;foo&#39;</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
  File <span class="nb">&quot;&lt;stdin&gt;&quot;</span>, line <span class="m">1</span>, in <span class="n">&lt;module&gt;</span>
<span class="gr">TypeError</span>: <span class="n">unorderable types: PureWindowsPath() &lt; PurePosixPath()</span>
<span class="gt">Traceback (most recent call last):</span>
  File <span class="nb">&quot;&lt;stdin&gt;&quot;</span>, line <span class="m">1</span>, in <span class="n">&lt;module&gt;</span>
<span class="gr">TypeError</span>: <span class="n">unorderable types: PureWindowsPath() &lt; PurePosixPath()</span>
</pre></div>
</div>
</div>
<div class="section" id="operators">
<h3>Operators<a class="headerlink" href="#operators" title="Permalink to this headline"></a></h3>
<p>The slash operator helps create child paths, similarly to <tt class="docutils literal"><span class="pre">os.path.join</span></tt>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">PurePath</span><span class="p">(</span><span class="s">&#39;/etc&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span>
<span class="go">PurePosixPath(&#39;/etc&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">/</span> <span class="s">&#39;init.d&#39;</span> <span class="o">/</span> <span class="s">&#39;apache2&#39;</span>
<span class="go">PurePosixPath(&#39;/etc/init.d/apache2&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">q</span> <span class="o">=</span> <span class="n">PurePath</span><span class="p">(</span><span class="s">&#39;bin&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="s">&#39;/usr&#39;</span> <span class="o">/</span> <span class="n">q</span>
<span class="go">PurePosixPath(&#39;/usr/bin&#39;)</span>
</pre></div>
</div>
<p>The string representation of a path is the raw filesystem path itself
(in native form, e.g. with backslashes under Windows), which you can
pass to any function taking a file path as a string:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">PurePath</span><span class="p">(</span><span class="s">&#39;/etc&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">str</span><span class="p">(</span><span class="n">p</span><span class="p">)</span>
<span class="go">&#39;/etc&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;c:/Program Files&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">str</span><span class="p">(</span><span class="n">p</span><span class="p">)</span>
<span class="go">&#39;c:\\Program Files&#39;</span>
</pre></div>
</div>
<p>Similarly, calling <tt class="docutils literal"><span class="pre">bytes</span></tt> on a path gives the raw filesystem path as a
bytes object, as encoded by <tt class="docutils literal"><span class="pre">os.fsencode</span></tt>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="nb">bytes</span><span class="p">(</span><span class="n">p</span><span class="p">)</span>
<span class="go">b&#39;/etc&#39;</span>
</pre></div>
</div>
</div>
<div class="section" id="accessing-individual-parts">
<h3>Accessing individual parts<a class="headerlink" href="#accessing-individual-parts" title="Permalink to this headline"></a></h3>
<p>To access the individual &#8220;parts&#8221; (components) of a path, use the following
property:</p>
<dl class="data">
<dt id="pathlib.PurePath.parts">
<tt class="descclassname">PurePath.</tt><tt class="descname">parts</tt><a class="headerlink" href="#pathlib.PurePath.parts" title="Permalink to this definition"></a></dt>
<dd><p>A tuple giving access to the path&#8217;s various components:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">PurePath</span><span class="p">(</span><span class="s">&#39;/usr/bin/python3&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">parts</span>
<span class="go">(&#39;/&#39;, &#39;usr&#39;, &#39;bin&#39;, &#39;python3&#39;)</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;c:/Program Files/PSF&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">parts</span>
<span class="go">(&#39;c:\\&#39;, &#39;Program Files&#39;, &#39;PSF&#39;)</span>
</pre></div>
</div>
<p>(note how the drive and local root are regrouped in a single part)</p>
</dd></dl>

</div>
<div class="section" id="methods-and-properties">
<h3>Methods and properties<a class="headerlink" href="#methods-and-properties" title="Permalink to this headline"></a></h3>
<p>Pure paths provide the following methods and properties:</p>
<dl class="data">
<dt id="pathlib.PurePath.drive">
<tt class="descclassname">PurePath.</tt><tt class="descname">drive</tt><a class="headerlink" href="#pathlib.PurePath.drive" title="Permalink to this definition"></a></dt>
<dd><p>A string representing the drive letter or name, if any:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;c:/Program Files/&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">drive</span>
<span class="go">&#39;c:&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;/Program Files/&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">drive</span>
<span class="go">&#39;&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;/etc&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">drive</span>
<span class="go">&#39;&#39;</span>
</pre></div>
</div>
<p>UNC shares are also considered drives:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;//host/share/foo.txt&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">drive</span>
<span class="go">&#39;\\\\host\\share&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="data">
<dt id="pathlib.PurePath.root">
<tt class="descclassname">PurePath.</tt><tt class="descname">root</tt><a class="headerlink" href="#pathlib.PurePath.root" title="Permalink to this definition"></a></dt>
<dd><p>A string representing the (local or global) root, if any:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;c:/Program Files/&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">root</span>
<span class="go">&#39;\\&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;c:Program Files/&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">root</span>
<span class="go">&#39;&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;/etc&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">root</span>
<span class="go">&#39;/&#39;</span>
</pre></div>
</div>
<p>UNC shares always have a root:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;//host/share&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">root</span>
<span class="go">&#39;\\&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="data">
<dt id="pathlib.PurePath.anchor">
<tt class="descclassname">PurePath.</tt><tt class="descname">anchor</tt><a class="headerlink" href="#pathlib.PurePath.anchor" title="Permalink to this definition"></a></dt>
<dd><p>The concatenation of the drive and root:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;c:/Program Files/&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">anchor</span>
<span class="go">&#39;c:\\&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;c:Program Files/&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">anchor</span>
<span class="go">&#39;c:&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;/etc&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">anchor</span>
<span class="go">&#39;/&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;//host/share&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">anchor</span>
<span class="go">&#39;\\\\host\\share\\&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="data">
<dt id="pathlib.PurePath.parents">
<tt class="descclassname">PurePath.</tt><tt class="descname">parents</tt><a class="headerlink" href="#pathlib.PurePath.parents" title="Permalink to this definition"></a></dt>
<dd><p>An immutable sequence providing access to the logical ancestors of
the path:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;c:/foo/bar/setup.py&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">parents</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="go">PureWindowsPath(&#39;c:/foo/bar&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">parents</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
<span class="go">PureWindowsPath(&#39;c:/foo&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">parents</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
<span class="go">PureWindowsPath(&#39;c:/&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="data">
<dt id="pathlib.PurePath.parent">
<tt class="descclassname">PurePath.</tt><tt class="descname">parent</tt><a class="headerlink" href="#pathlib.PurePath.parent" title="Permalink to this definition"></a></dt>
<dd><p>The logical parent of the path:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;/a/b/c/d&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">parent</span>
<span class="go">PurePosixPath(&#39;/a/b/c&#39;)</span>
</pre></div>
</div>
<p>You cannot go past an anchor, or empty path:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;/&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">parent</span>
<span class="go">PurePosixPath(&#39;/&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;.&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">parent</span>
<span class="go">PurePosixPath(&#39;.&#39;)</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>This is a purely lexical operation, hence the following behaviour:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;foo/..&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">parent</span>
<span class="go">PurePosixPath(&#39;foo&#39;)</span>
</pre></div>
</div>
<p class="last">If you want to walk an arbitrary filesystem path upwards, it is
recommended to first call <a class="reference internal" href="#pathlib.Path.resolve" title="pathlib.Path.resolve"><tt class="xref py py-meth docutils literal"><span class="pre">Path.resolve()</span></tt></a> so as to resolve
symlinks and eliminate <cite>&#8221;..&#8221;</cite> components.</p>
</div>
</dd></dl>

<dl class="data">
<dt id="pathlib.PurePath.name">
<tt class="descclassname">PurePath.</tt><tt class="descname">name</tt><a class="headerlink" href="#pathlib.PurePath.name" title="Permalink to this definition"></a></dt>
<dd><p>A string representing the final path component, excluding the drive and
root, if any:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;my/library/setup.py&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">name</span>
<span class="go">&#39;setup.py&#39;</span>
</pre></div>
</div>
<p>UNC drive names are not considered:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;//some/share/setup.py&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">name</span>
<span class="go">&#39;setup.py&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;//some/share&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">name</span>
<span class="go">&#39;&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="data">
<dt id="pathlib.PurePath.suffix">
<tt class="descclassname">PurePath.</tt><tt class="descname">suffix</tt><a class="headerlink" href="#pathlib.PurePath.suffix" title="Permalink to this definition"></a></dt>
<dd><p>The file extension of the final component, if any:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;my/library/setup.py&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">suffix</span>
<span class="go">&#39;.py&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;my/library.tar.gz&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">suffix</span>
<span class="go">&#39;.gz&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;my/library&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">suffix</span>
<span class="go">&#39;&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="data">
<dt id="pathlib.PurePath.suffixes">
<tt class="descclassname">PurePath.</tt><tt class="descname">suffixes</tt><a class="headerlink" href="#pathlib.PurePath.suffixes" title="Permalink to this definition"></a></dt>
<dd><p>A list of the path&#8217;s file extensions:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;my/library.tar.gar&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">suffixes</span>
<span class="go">[&#39;.tar&#39;, &#39;.gar&#39;]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;my/library.tar.gz&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">suffixes</span>
<span class="go">[&#39;.tar&#39;, &#39;.gz&#39;]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;my/library&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">suffixes</span>
<span class="go">[]</span>
</pre></div>
</div>
</dd></dl>

<dl class="data">
<dt id="pathlib.PurePath.stem">
<tt class="descclassname">PurePath.</tt><tt class="descname">stem</tt><a class="headerlink" href="#pathlib.PurePath.stem" title="Permalink to this definition"></a></dt>
<dd><p>The final path component, without its suffix:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;my/library.tar.gz&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">stem</span>
<span class="go">&#39;library.tar&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;my/library.tar&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">stem</span>
<span class="go">&#39;library&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;my/library&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">stem</span>
<span class="go">&#39;library&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="pathlib.PurePath.as_posix">
<tt class="descclassname">PurePath.</tt><tt class="descname">as_posix</tt><big>(</big><big>)</big><a class="headerlink" href="#pathlib.PurePath.as_posix" title="Permalink to this definition"></a></dt>
<dd><p>Return a string representation of the path with forward slashes (<tt class="docutils literal"><span class="pre">/</span></tt>):</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;c:</span><span class="se">\\</span><span class="s">windows&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">str</span><span class="p">(</span><span class="n">p</span><span class="p">)</span>
<span class="go">&#39;c:\\windows&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">as_posix</span><span class="p">()</span>
<span class="go">&#39;c:/windows&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="pathlib.PurePath.as_uri">
<tt class="descclassname">PurePath.</tt><tt class="descname">as_uri</tt><big>(</big><big>)</big><a class="headerlink" href="#pathlib.PurePath.as_uri" title="Permalink to this definition"></a></dt>
<dd><p>Represent the path as a <tt class="docutils literal"><span class="pre">file</span></tt> URI.  <tt class="xref py py-exc docutils literal"><span class="pre">ValueError</span></tt> is raised if
the path isn&#8217;t absolute.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;/etc/passwd&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">as_uri</span><span class="p">()</span>
<span class="go">&#39;file:///etc/passwd&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;c:/Windows&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">as_uri</span><span class="p">()</span>
<span class="go">&#39;file:///c:/Windows&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="pathlib.PurePath.is_absolute">
<tt class="descclassname">PurePath.</tt><tt class="descname">is_absolute</tt><big>(</big><big>)</big><a class="headerlink" href="#pathlib.PurePath.is_absolute" title="Permalink to this definition"></a></dt>
<dd><p>Return whether the path is absolute or not.  A path is considered absolute
if it has both a root and (if the flavour allows) a drive:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;/a/b&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">is_absolute</span><span class="p">()</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;a/b&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">is_absolute</span><span class="p">()</span>
<span class="go">False</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;c:/a/b&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">is_absolute</span><span class="p">()</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;/a/b&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">is_absolute</span><span class="p">()</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;c:&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">is_absolute</span><span class="p">()</span>
<span class="go">False</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;//some/share&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">is_absolute</span><span class="p">()</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="pathlib.PurePath.is_reserved">
<tt class="descclassname">PurePath.</tt><tt class="descname">is_reserved</tt><big>(</big><big>)</big><a class="headerlink" href="#pathlib.PurePath.is_reserved" title="Permalink to this definition"></a></dt>
<dd><p>With <a class="reference internal" href="#pathlib.PureWindowsPath" title="pathlib.PureWindowsPath"><tt class="xref py py-class docutils literal"><span class="pre">PureWindowsPath</span></tt></a>, return <tt class="docutils literal"><span class="pre">True</span></tt> if the path is considered
reserved under Windows, <tt class="docutils literal"><span class="pre">False</span></tt> otherwise.  With <a class="reference internal" href="#pathlib.PurePosixPath" title="pathlib.PurePosixPath"><tt class="xref py py-class docutils literal"><span class="pre">PurePosixPath</span></tt></a>,
<tt class="docutils literal"><span class="pre">False</span></tt> is always returned.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;nul&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">is_reserved</span><span class="p">()</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;nul&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">is_reserved</span><span class="p">()</span>
<span class="go">False</span>
</pre></div>
</div>
<p>File system calls on reserved paths can fail mysteriously or have
unintended effects.</p>
</dd></dl>

<dl class="method">
<dt id="pathlib.PurePath.joinpath">
<tt class="descclassname">PurePath.</tt><tt class="descname">joinpath</tt><big>(</big><em>*other</em><big>)</big><a class="headerlink" href="#pathlib.PurePath.joinpath" title="Permalink to this definition"></a></dt>
<dd><p>Calling this method is equivalent to combining the path with each of
the <em>other</em> arguments in turn:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;/etc&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">joinpath</span><span class="p">(</span><span class="s">&#39;passwd&#39;</span><span class="p">)</span>
<span class="go">PurePosixPath(&#39;/etc/passwd&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;/etc&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">joinpath</span><span class="p">(</span><span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;passwd&#39;</span><span class="p">))</span>
<span class="go">PurePosixPath(&#39;/etc/passwd&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;/etc&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">joinpath</span><span class="p">(</span><span class="s">&#39;init.d&#39;</span><span class="p">,</span> <span class="s">&#39;apache2&#39;</span><span class="p">)</span>
<span class="go">PurePosixPath(&#39;/etc/init.d/apache2&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;c:&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">joinpath</span><span class="p">(</span><span class="s">&#39;/Program Files&#39;</span><span class="p">)</span>
<span class="go">PureWindowsPath(&#39;c:/Program Files&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="pathlib.PurePath.match">
<tt class="descclassname">PurePath.</tt><tt class="descname">match</tt><big>(</big><em>pattern</em><big>)</big><a class="headerlink" href="#pathlib.PurePath.match" title="Permalink to this definition"></a></dt>
<dd><p>Match this path against the provided glob-style pattern.  Return <tt class="docutils literal"><span class="pre">True</span></tt>
if matching is successful, <tt class="docutils literal"><span class="pre">False</span></tt> otherwise.</p>
<p>If <em>pattern</em> is relative, the path can be either relative or absolute,
and matching is done from the right:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PurePath</span><span class="p">(</span><span class="s">&#39;a/b.py&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="s">&#39;*.py&#39;</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PurePath</span><span class="p">(</span><span class="s">&#39;/a/b/c.py&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="s">&#39;b/*.py&#39;</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PurePath</span><span class="p">(</span><span class="s">&#39;/a/b/c.py&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="s">&#39;a/*.py&#39;</span><span class="p">)</span>
<span class="go">False</span>
</pre></div>
</div>
<p>If <em>pattern</em> is absolute, the path must be absolute, and the whole path
must match:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PurePath</span><span class="p">(</span><span class="s">&#39;/a.py&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="s">&#39;/*.py&#39;</span><span class="p">)</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PurePath</span><span class="p">(</span><span class="s">&#39;a/b.py&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="s">&#39;/*.py&#39;</span><span class="p">)</span>
<span class="go">False</span>
</pre></div>
</div>
<p>As with other methods, case-sensitivity is observed:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;b.py&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="s">&#39;*.PY&#39;</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="pathlib.PurePath.relative_to">
<tt class="descclassname">PurePath.</tt><tt class="descname">relative_to</tt><big>(</big><em>*other</em><big>)</big><a class="headerlink" href="#pathlib.PurePath.relative_to" title="Permalink to this definition"></a></dt>
<dd><p>Compute a version of this path relative to the path represented by
<em>other</em>.  If it&#8217;s impossible, ValueError is raised:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">PurePosixPath</span><span class="p">(</span><span class="s">&#39;/etc/passwd&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">relative_to</span><span class="p">(</span><span class="s">&#39;/&#39;</span><span class="p">)</span>
<span class="go">PurePosixPath(&#39;etc/passwd&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">relative_to</span><span class="p">(</span><span class="s">&#39;/etc&#39;</span><span class="p">)</span>
<span class="go">PurePosixPath(&#39;passwd&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">relative_to</span><span class="p">(</span><span class="s">&#39;/usr&#39;</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
  File <span class="nb">&quot;&lt;stdin&gt;&quot;</span>, line <span class="m">1</span>, in <span class="n">&lt;module&gt;</span>
  File <span class="nb">&quot;pathlib.py&quot;</span>, line <span class="m">694</span>, in <span class="n">relative_to</span>
    <span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="p">),</span> <span class="nb">str</span><span class="p">(</span><span class="n">formatted</span><span class="p">)))</span>
<span class="gr">ValueError</span>: <span class="n">&#39;/etc/passwd&#39; does not start with &#39;/usr&#39;</span>
<span class="gt">Traceback (most recent call last):</span>
  File <span class="nb">&quot;&lt;stdin&gt;&quot;</span>, line <span class="m">1</span>, in <span class="n">&lt;module&gt;</span>
  File <span class="nb">&quot;pathlib.py&quot;</span>, line <span class="m">694</span>, in <span class="n">relative_to</span>
    <span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="p">),</span> <span class="nb">str</span><span class="p">(</span><span class="n">formatted</span><span class="p">)))</span>
<span class="gr">ValueError</span>: <span class="n">&#39;/etc/passwd&#39; does not start with &#39;/usr&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="pathlib.PurePath.with_name">
<tt class="descclassname">PurePath.</tt><tt class="descname">with_name</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#pathlib.PurePath.with_name" title="Permalink to this definition"></a></dt>
<dd><p>Return a new path with the <a class="reference internal" href="#pathlib.PurePath.name" title="pathlib.PurePath.name"><tt class="xref py py-attr docutils literal"><span class="pre">name</span></tt></a> changed.  If the original path
doesn&#8217;t have a name, ValueError is raised:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;c:/Downloads/pathlib.tar.gz&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">with_name</span><span class="p">(</span><span class="s">&#39;setup.py&#39;</span><span class="p">)</span>
<span class="go">PureWindowsPath(&#39;c:/Downloads/setup.py&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;c:/&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">with_name</span><span class="p">(</span><span class="s">&#39;setup.py&#39;</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
  File <span class="nb">&quot;&lt;stdin&gt;&quot;</span>, line <span class="m">1</span>, in <span class="n">&lt;module&gt;</span>
  File <span class="nb">&quot;/home/antoine/cpython/default/Lib/pathlib.py&quot;</span>, line <span class="m">751</span>, in <span class="n">with_name</span>
    <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%r</span><span class="s"> has an empty name&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="p">,))</span>
<span class="gr">ValueError</span>: <span class="n">PureWindowsPath(&#39;c:/&#39;) has an empty name</span>
<span class="gt">Traceback (most recent call last):</span>
  File <span class="nb">&quot;&lt;stdin&gt;&quot;</span>, line <span class="m">1</span>, in <span class="n">&lt;module&gt;</span>
  File <span class="nb">&quot;/home/antoine/cpython/default/Lib/pathlib.py&quot;</span>, line <span class="m">751</span>, in <span class="n">with_name</span>
    <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%r</span><span class="s"> has an empty name&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="p">,))</span>
<span class="gr">ValueError</span>: <span class="n">PureWindowsPath(&#39;c:/&#39;) has an empty name</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="pathlib.PurePath.with_suffix">
<tt class="descclassname">PurePath.</tt><tt class="descname">with_suffix</tt><big>(</big><em>suffix</em><big>)</big><a class="headerlink" href="#pathlib.PurePath.with_suffix" title="Permalink to this definition"></a></dt>
<dd><p>Return a new path with the <a class="reference internal" href="#pathlib.PurePath.suffix" title="pathlib.PurePath.suffix"><tt class="xref py py-attr docutils literal"><span class="pre">suffix</span></tt></a> changed.  If the original path
doesn&#8217;t have a suffix, the new <em>suffix</em> is appended instead:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;c:/Downloads/pathlib.tar.gz&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">with_suffix</span><span class="p">(</span><span class="s">&#39;.bz2&#39;</span><span class="p">)</span>
<span class="go">PureWindowsPath(&#39;c:/Downloads/pathlib.tar.bz2&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">PureWindowsPath</span><span class="p">(</span><span class="s">&#39;README&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">with_suffix</span><span class="p">(</span><span class="s">&#39;.txt&#39;</span><span class="p">)</span>
<span class="go">PureWindowsPath(&#39;README.txt&#39;)</span>
</pre></div>
</div>
</dd></dl>

</div>
</div>
<div class="section" id="concrete-paths">
<span id="id2"></span><h2>Concrete paths<a class="headerlink" href="#concrete-paths" title="Permalink to this headline"></a></h2>
<p>Concrete paths are subclasses of the pure path classes.  In addition to
operations provided by the latter, they also provide methods to do system
calls on path objects.  There are three ways to instantiate concrete paths:</p>
<dl class="class">
<dt id="pathlib.Path">
<em class="property">class </em><tt class="descclassname">pathlib.</tt><tt class="descname">Path</tt><big>(</big><em>*pathsegments</em><big>)</big><a class="headerlink" href="#pathlib.Path" title="Permalink to this definition"></a></dt>
<dd><p>A subclass of <a class="reference internal" href="#pathlib.PurePath" title="pathlib.PurePath"><tt class="xref py py-class docutils literal"><span class="pre">PurePath</span></tt></a>, this class represents concrete paths of
the system&#8217;s path flavour (instantiating it creates either a
<a class="reference internal" href="#pathlib.PosixPath" title="pathlib.PosixPath"><tt class="xref py py-class docutils literal"><span class="pre">PosixPath</span></tt></a> or a <a class="reference internal" href="#pathlib.WindowsPath" title="pathlib.WindowsPath"><tt class="xref py py-class docutils literal"><span class="pre">WindowsPath</span></tt></a>):</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">Path</span><span class="p">(</span><span class="s">&#39;setup.py&#39;</span><span class="p">)</span>
<span class="go">PosixPath(&#39;setup.py&#39;)</span>
</pre></div>
</div>
<p><em>pathsegments</em> is specified similarly to <a class="reference internal" href="#pathlib.PurePath" title="pathlib.PurePath"><tt class="xref py py-class docutils literal"><span class="pre">PurePath</span></tt></a>.</p>
</dd></dl>

<dl class="class">
<dt id="pathlib.PosixPath">
<em class="property">class </em><tt class="descclassname">pathlib.</tt><tt class="descname">PosixPath</tt><big>(</big><em>*pathsegments</em><big>)</big><a class="headerlink" href="#pathlib.PosixPath" title="Permalink to this definition"></a></dt>
<dd><p>A subclass of <a class="reference internal" href="#pathlib.Path" title="pathlib.Path"><tt class="xref py py-class docutils literal"><span class="pre">Path</span></tt></a> and <a class="reference internal" href="#pathlib.PurePosixPath" title="pathlib.PurePosixPath"><tt class="xref py py-class docutils literal"><span class="pre">PurePosixPath</span></tt></a>, this class
represents concrete non-Windows filesystem paths:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">PosixPath</span><span class="p">(</span><span class="s">&#39;/etc&#39;</span><span class="p">)</span>
<span class="go">PosixPath(&#39;/etc&#39;)</span>
</pre></div>
</div>
<p><em>pathsegments</em> is specified similarly to <a class="reference internal" href="#pathlib.PurePath" title="pathlib.PurePath"><tt class="xref py py-class docutils literal"><span class="pre">PurePath</span></tt></a>.</p>
</dd></dl>

<dl class="class">
<dt id="pathlib.WindowsPath">
<em class="property">class </em><tt class="descclassname">pathlib.</tt><tt class="descname">WindowsPath</tt><big>(</big><em>*pathsegments</em><big>)</big><a class="headerlink" href="#pathlib.WindowsPath" title="Permalink to this definition"></a></dt>
<dd><p>A subclass of <a class="reference internal" href="#pathlib.Path" title="pathlib.Path"><tt class="xref py py-class docutils literal"><span class="pre">Path</span></tt></a> and <a class="reference internal" href="#pathlib.PureWindowsPath" title="pathlib.PureWindowsPath"><tt class="xref py py-class docutils literal"><span class="pre">PureWindowsPath</span></tt></a>, this class
represents concrete Windows filesystem paths:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">WindowsPath</span><span class="p">(</span><span class="s">&#39;c:/Program Files/&#39;</span><span class="p">)</span>
<span class="go">WindowsPath(&#39;c:/Program Files&#39;)</span>
</pre></div>
</div>
<p><em>pathsegments</em> is specified similarly to <a class="reference internal" href="#pathlib.PurePath" title="pathlib.PurePath"><tt class="xref py py-class docutils literal"><span class="pre">PurePath</span></tt></a>.</p>
</dd></dl>

<p>You can only instantiate the class flavour that corresponds to your system
(allowing system calls on non-compatible path flavours could lead to
bugs or failures in your application):</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">os</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">os</span><span class="o">.</span><span class="n">name</span>
<span class="go">&#39;posix&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Path</span><span class="p">(</span><span class="s">&#39;setup.py&#39;</span><span class="p">)</span>
<span class="go">PosixPath(&#39;setup.py&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">PosixPath</span><span class="p">(</span><span class="s">&#39;setup.py&#39;</span><span class="p">)</span>
<span class="go">PosixPath(&#39;setup.py&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">WindowsPath</span><span class="p">(</span><span class="s">&#39;setup.py&#39;</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
  File <span class="nb">&quot;&lt;stdin&gt;&quot;</span>, line <span class="m">1</span>, in <span class="n">&lt;module&gt;</span>
  File <span class="nb">&quot;pathlib.py&quot;</span>, line <span class="m">798</span>, in <span class="n">__new__</span>
    <span class="o">%</span> <span class="p">(</span><span class="n">cls</span><span class="o">.</span><span class="n">__name__</span><span class="p">,))</span>
<span class="gr">NotImplementedError</span>: <span class="n">cannot instantiate &#39;WindowsPath&#39; on your system</span>
<span class="gt">Traceback (most recent call last):</span>
  File <span class="nb">&quot;&lt;stdin&gt;&quot;</span>, line <span class="m">1</span>, in <span class="n">&lt;module&gt;</span>
  File <span class="nb">&quot;pathlib.py&quot;</span>, line <span class="m">798</span>, in <span class="n">__new__</span>
    <span class="o">%</span> <span class="p">(</span><span class="n">cls</span><span class="o">.</span><span class="n">__name__</span><span class="p">,))</span>
<span class="gr">NotImplementedError</span>: <span class="n">cannot instantiate &#39;WindowsPath&#39; on your system</span>
</pre></div>
</div>
<div class="section" id="methods">
<h3>Methods<a class="headerlink" href="#methods" title="Permalink to this headline"></a></h3>
<p>Concrete paths provide the following methods in addition to pure paths
methods.  Many of these methods can raise an <tt class="xref py py-exc docutils literal"><span class="pre">OSError</span></tt> if a system
call fails (for example because the path doesn&#8217;t exist):</p>
<dl class="classmethod">
<dt id="pathlib.Path.cwd">
<em class="property">classmethod </em><tt class="descclassname">Path.</tt><tt class="descname">cwd</tt><big>(</big><big>)</big><a class="headerlink" href="#pathlib.Path.cwd" title="Permalink to this definition"></a></dt>
<dd><p>Return a new path object representing the current directory (as returned
by <tt class="xref py py-func docutils literal"><span class="pre">os.getcwd()</span></tt>):</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">Path</span><span class="o">.</span><span class="n">cwd</span><span class="p">()</span>
<span class="go">PosixPath(&#39;/home/antoine/pathlib&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.stat">
<tt class="descclassname">Path.</tt><tt class="descname">stat</tt><big>(</big><big>)</big><a class="headerlink" href="#pathlib.Path.stat" title="Permalink to this definition"></a></dt>
<dd><p>Return information about this path (similarly to <tt class="xref py py-func docutils literal"><span class="pre">os.stat()</span></tt>).
The result is looked up at each call to this method.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="s">&#39;setup.py&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">stat</span><span class="p">()</span><span class="o">.</span><span class="n">st_size</span>
<span class="go">956</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">stat</span><span class="p">()</span><span class="o">.</span><span class="n">st_mtime</span>
<span class="go">1327883547.852554</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.chmod">
<tt class="descclassname">Path.</tt><tt class="descname">chmod</tt><big>(</big><em>mode</em><big>)</big><a class="headerlink" href="#pathlib.Path.chmod" title="Permalink to this definition"></a></dt>
<dd><p>Change the file mode and permissions, like <tt class="xref py py-func docutils literal"><span class="pre">os.chmod()</span></tt>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="s">&#39;setup.py&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">stat</span><span class="p">()</span><span class="o">.</span><span class="n">st_mode</span>
<span class="go">33277</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">chmod</span><span class="p">(</span><span class="mi">0</span><span class="n">o444</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">stat</span><span class="p">()</span><span class="o">.</span><span class="n">st_mode</span>
<span class="go">33060</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.exists">
<tt class="descclassname">Path.</tt><tt class="descname">exists</tt><big>(</big><big>)</big><a class="headerlink" href="#pathlib.Path.exists" title="Permalink to this definition"></a></dt>
<dd><p>Whether the path points to an existing file or directory:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pathlib</span> <span class="kn">import</span> <span class="o">*</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Path</span><span class="p">(</span><span class="s">&#39;.&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">exists</span><span class="p">()</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Path</span><span class="p">(</span><span class="s">&#39;setup.py&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">exists</span><span class="p">()</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Path</span><span class="p">(</span><span class="s">&#39;/etc&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">exists</span><span class="p">()</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">Path</span><span class="p">(</span><span class="s">&#39;nonexistentfile&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">exists</span><span class="p">()</span>
<span class="go">False</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.glob">
<tt class="descclassname">Path.</tt><tt class="descname">glob</tt><big>(</big><em>pattern</em><big>)</big><a class="headerlink" href="#pathlib.Path.glob" title="Permalink to this definition"></a></dt>
<dd><p>Glob the given <em>pattern</em> in the directory represented by this path,
yielding all matching files (of any kind):</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">Path</span><span class="p">(</span><span class="s">&#39;.&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="s">&#39;*.py&#39;</span><span class="p">))</span>
<span class="go">[PosixPath(&#39;pathlib.py&#39;), PosixPath(&#39;setup.py&#39;), PosixPath(&#39;test_pathlib.py&#39;)]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">Path</span><span class="p">(</span><span class="s">&#39;.&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="s">&#39;*/*.py&#39;</span><span class="p">))</span>
<span class="go">[PosixPath(&#39;docs/conf.py&#39;)]</span>
</pre></div>
</div>
<p>The &#8220;<tt class="docutils literal"><span class="pre">**</span></tt>&#8221; pattern means &#8220;this directory and all subdirectories,
recursively&#8221;.  In other words, it enables recursive globbing:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">Path</span><span class="p">(</span><span class="s">&#39;.&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">glob</span><span class="p">(</span><span class="s">&#39;**/*.py&#39;</span><span class="p">))</span>
<span class="go">[PosixPath(&#39;build/lib/pathlib.py&#39;),</span>
<span class="go"> PosixPath(&#39;docs/conf.py&#39;),</span>
<span class="go"> PosixPath(&#39;pathlib.py&#39;),</span>
<span class="go"> PosixPath(&#39;setup.py&#39;),</span>
<span class="go"> PosixPath(&#39;test_pathlib.py&#39;)]</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Using the &#8220;<tt class="docutils literal"><span class="pre">**</span></tt>&#8221; pattern in large directory trees may consume
an inordinate amount of time.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.group">
<tt class="descclassname">Path.</tt><tt class="descname">group</tt><big>(</big><big>)</big><a class="headerlink" href="#pathlib.Path.group" title="Permalink to this definition"></a></dt>
<dd><p>Return the name of the group owning the file.  <tt class="xref py py-exc docutils literal"><span class="pre">KeyError</span></tt> is raised
if the file&#8217;s gid isn&#8217;t found in the system database.</p>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.is_dir">
<tt class="descclassname">Path.</tt><tt class="descname">is_dir</tt><big>(</big><big>)</big><a class="headerlink" href="#pathlib.Path.is_dir" title="Permalink to this definition"></a></dt>
<dd><p>Return <tt class="docutils literal"><span class="pre">True</span></tt> if the path points to a directory (or a symbolic link
pointing to a directory), <tt class="docutils literal"><span class="pre">False</span></tt> if it points to another kind of file.</p>
<p><tt class="docutils literal"><span class="pre">False</span></tt> is also returned if the path doesn&#8217;t exist or is a broken symlink;
other errors (such as permission errors) are propagated.</p>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.is_file">
<tt class="descclassname">Path.</tt><tt class="descname">is_file</tt><big>(</big><big>)</big><a class="headerlink" href="#pathlib.Path.is_file" title="Permalink to this definition"></a></dt>
<dd><p>Return <tt class="docutils literal"><span class="pre">True</span></tt> if the path points to a regular file (or a symbolic link
pointing to a regular file), <tt class="docutils literal"><span class="pre">False</span></tt> if it points to another kind of file.</p>
<p><tt class="docutils literal"><span class="pre">False</span></tt> is also returned if the path doesn&#8217;t exist or is a broken symlink;
other errors (such as permission errors) are propagated.</p>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.is_symlink">
<tt class="descclassname">Path.</tt><tt class="descname">is_symlink</tt><big>(</big><big>)</big><a class="headerlink" href="#pathlib.Path.is_symlink" title="Permalink to this definition"></a></dt>
<dd><p>Return <tt class="docutils literal"><span class="pre">True</span></tt> if the path points to a symbolic link, <tt class="docutils literal"><span class="pre">False</span></tt> otherwise.</p>
<p><tt class="docutils literal"><span class="pre">False</span></tt> is also returned if the path doesn&#8217;t exist; other errors (such
as permission errors) are propagated.</p>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.is_socket">
<tt class="descclassname">Path.</tt><tt class="descname">is_socket</tt><big>(</big><big>)</big><a class="headerlink" href="#pathlib.Path.is_socket" title="Permalink to this definition"></a></dt>
<dd><p>Return <tt class="docutils literal"><span class="pre">True</span></tt> if the path points to a Unix socket (or a symbolic link
pointing to a Unix socket), <tt class="docutils literal"><span class="pre">False</span></tt> if it points to another kind of file.</p>
<p><tt class="docutils literal"><span class="pre">False</span></tt> is also returned if the path doesn&#8217;t exist or is a broken symlink;
other errors (such as permission errors) are propagated.</p>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.is_fifo">
<tt class="descclassname">Path.</tt><tt class="descname">is_fifo</tt><big>(</big><big>)</big><a class="headerlink" href="#pathlib.Path.is_fifo" title="Permalink to this definition"></a></dt>
<dd><p>Return <tt class="docutils literal"><span class="pre">True</span></tt> if the path points to a FIFO (or a symbolic link
pointing to a FIFO), <tt class="docutils literal"><span class="pre">False</span></tt> if it points to another kind of file.</p>
<p><tt class="docutils literal"><span class="pre">False</span></tt> is also returned if the path doesn&#8217;t exist or is a broken symlink;
other errors (such as permission errors) are propagated.</p>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.is_block_device">
<tt class="descclassname">Path.</tt><tt class="descname">is_block_device</tt><big>(</big><big>)</big><a class="headerlink" href="#pathlib.Path.is_block_device" title="Permalink to this definition"></a></dt>
<dd><p>Return <tt class="docutils literal"><span class="pre">True</span></tt> if the path points to a block device (or a symbolic link
pointing to a block device), <tt class="docutils literal"><span class="pre">False</span></tt> if it points to another kind of file.</p>
<p><tt class="docutils literal"><span class="pre">False</span></tt> is also returned if the path doesn&#8217;t exist or is a broken symlink;
other errors (such as permission errors) are propagated.</p>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.is_char_device">
<tt class="descclassname">Path.</tt><tt class="descname">is_char_device</tt><big>(</big><big>)</big><a class="headerlink" href="#pathlib.Path.is_char_device" title="Permalink to this definition"></a></dt>
<dd><p>Return <tt class="docutils literal"><span class="pre">True</span></tt> if the path points to a character device (or a symbolic link
pointing to a character device), <tt class="docutils literal"><span class="pre">False</span></tt> if it points to another kind of file.</p>
<p><tt class="docutils literal"><span class="pre">False</span></tt> is also returned if the path doesn&#8217;t exist or is a broken symlink;
other errors (such as permission errors) are propagated.</p>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.iterdir">
<tt class="descclassname">Path.</tt><tt class="descname">iterdir</tt><big>(</big><big>)</big><a class="headerlink" href="#pathlib.Path.iterdir" title="Permalink to this definition"></a></dt>
<dd><p>When the path points to a directory, yield path objects of the directory
contents:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="s">&#39;docs&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">child</span> <span class="ow">in</span> <span class="n">p</span><span class="o">.</span><span class="n">iterdir</span><span class="p">():</span> <span class="n">child</span>
<span class="gp">...</span>
<span class="go">PosixPath(&#39;docs/conf.py&#39;)</span>
<span class="go">PosixPath(&#39;docs/_templates&#39;)</span>
<span class="go">PosixPath(&#39;docs/make.bat&#39;)</span>
<span class="go">PosixPath(&#39;docs/index.rst&#39;)</span>
<span class="go">PosixPath(&#39;docs/_build&#39;)</span>
<span class="go">PosixPath(&#39;docs/_static&#39;)</span>
<span class="go">PosixPath(&#39;docs/Makefile&#39;)</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.lchmod">
<tt class="descclassname">Path.</tt><tt class="descname">lchmod</tt><big>(</big><em>mode</em><big>)</big><a class="headerlink" href="#pathlib.Path.lchmod" title="Permalink to this definition"></a></dt>
<dd><p>Like <a class="reference internal" href="#pathlib.Path.chmod" title="pathlib.Path.chmod"><tt class="xref py py-meth docutils literal"><span class="pre">Path.chmod()</span></tt></a> but, if the path points to a symbolic link, the
symbolic link&#8217;s mode is changed rather than its target&#8217;s.</p>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.lstat">
<tt class="descclassname">Path.</tt><tt class="descname">lstat</tt><big>(</big><big>)</big><a class="headerlink" href="#pathlib.Path.lstat" title="Permalink to this definition"></a></dt>
<dd><p>Like <a class="reference internal" href="#pathlib.Path.stat" title="pathlib.Path.stat"><tt class="xref py py-meth docutils literal"><span class="pre">Path.stat()</span></tt></a> but, if the path points to a symbolic link, return
the symbolic link&#8217;s information rather than its target&#8217;s.</p>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.mkdir">
<tt class="descclassname">Path.</tt><tt class="descname">mkdir</tt><big>(</big><em>mode=0o777</em>, <em>parents=False</em><big>)</big><a class="headerlink" href="#pathlib.Path.mkdir" title="Permalink to this definition"></a></dt>
<dd><p>Create a new directory at this given path.  If <em>mode</em> is given, it is
combined with the process&#8217; <tt class="docutils literal"><span class="pre">umask</span></tt> value to determine the file mode
and access flags.  If the path already exists, <tt class="xref py py-exc docutils literal"><span class="pre">OSError</span></tt> is raised.</p>
<p>If <em>parents</em> is true, any missing parents of this path are created
as needed; they are created with the default permissions without taking
<em>mode</em> into account (mimicking the POSIX <tt class="docutils literal"><span class="pre">mkdir</span> <span class="pre">-p</span></tt> command).</p>
<p>If <em>parents</em> is false (the default), a missing parent raises
<tt class="xref py py-exc docutils literal"><span class="pre">OSError</span></tt>.</p>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.open">
<tt class="descclassname">Path.</tt><tt class="descname">open</tt><big>(</big><em>mode='r'</em>, <em>buffering=-1</em>, <em>encoding=None</em>, <em>errors=None</em>, <em>newline=None</em><big>)</big><a class="headerlink" href="#pathlib.Path.open" title="Permalink to this definition"></a></dt>
<dd><p>Open the file pointed to by the path, like the built-in <a class="reference internal" href="#pathlib.Path.open" title="pathlib.Path.open"><tt class="xref py py-func docutils literal"><span class="pre">open()</span></tt></a>
function does:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="s">&#39;setup.py&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="k">with</span> <span class="n">p</span><span class="o">.</span><span class="n">open</span><span class="p">()</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
<span class="gp">... </span>    <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
<span class="gp">...</span>
<span class="go">&#39;#!/usr/bin/env python3\n&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.owner">
<tt class="descclassname">Path.</tt><tt class="descname">owner</tt><big>(</big><big>)</big><a class="headerlink" href="#pathlib.Path.owner" title="Permalink to this definition"></a></dt>
<dd><p>Return the name of the user owning the file.  <tt class="xref py py-exc docutils literal"><span class="pre">KeyError</span></tt> is raised
if the file&#8217;s uid isn&#8217;t found in the system database.</p>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.rename">
<tt class="descclassname">Path.</tt><tt class="descname">rename</tt><big>(</big><em>target</em><big>)</big><a class="headerlink" href="#pathlib.Path.rename" title="Permalink to this definition"></a></dt>
<dd><p>Rename this file or directory to the given <em>target</em>.  <em>target</em> can be
either a string or another path object:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="s">&#39;foo&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s">&#39;w&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">&#39;some text&#39;</span><span class="p">)</span>
<span class="go">9</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">target</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="s">&#39;bar&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">rename</span><span class="p">(</span><span class="n">target</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">target</span><span class="o">.</span><span class="n">open</span><span class="p">()</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
<span class="go">&#39;some text&#39;</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.replace">
<tt class="descclassname">Path.</tt><tt class="descname">replace</tt><big>(</big><em>target</em><big>)</big><a class="headerlink" href="#pathlib.Path.replace" title="Permalink to this definition"></a></dt>
<dd><p>Rename this file or directory to the given <em>target</em>.  If <em>target</em> points
to an existing file or directory, it will be unconditionally replaced.</p>
<p>This method is only available with Python 3.3; it will raise
<tt class="xref py py-exc docutils literal"><span class="pre">NotImplementedError</span></tt> on previous Python versions.</p>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.resolve">
<tt class="descclassname">Path.</tt><tt class="descname">resolve</tt><big>(</big><big>)</big><a class="headerlink" href="#pathlib.Path.resolve" title="Permalink to this definition"></a></dt>
<dd><p>Make the path absolute, resolving any symlinks.  A new path object is
returned:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">Path</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span>
<span class="go">PosixPath(&#39;.&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">resolve</span><span class="p">()</span>
<span class="go">PosixPath(&#39;/home/antoine/pathlib&#39;)</span>
</pre></div>
</div>
<p><cite>&#8221;..&#8221;</cite> components are also eliminated (this is the only method to do so):</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="s">&#39;docs/../setup.py&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">resolve</span><span class="p">()</span>
<span class="go">PosixPath(&#39;/home/antoine/pathlib/setup.py&#39;)</span>
</pre></div>
</div>
<p>If the path doesn&#8217;t exist, an <tt class="xref py py-exc docutils literal"><span class="pre">OSError</span></tt> is raised.  If an infinite
loop is encountered along the resolution path, <tt class="xref py py-exc docutils literal"><span class="pre">RuntimeError</span></tt> is
raised.</p>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.rglob">
<tt class="descclassname">Path.</tt><tt class="descname">rglob</tt><big>(</big><em>pattern</em><big>)</big><a class="headerlink" href="#pathlib.Path.rglob" title="Permalink to this definition"></a></dt>
<dd><p>This is like calling <a class="reference internal" href="#pathlib.Path.glob" title="pathlib.Path.glob"><tt class="xref py py-meth docutils literal"><span class="pre">glob()</span></tt></a> with &#8220;<tt class="docutils literal"><span class="pre">**</span></tt>&#8221; added in front of the
given <em>pattern</em>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">Path</span><span class="p">()</span><span class="o">.</span><span class="n">rglob</span><span class="p">(</span><span class="s">&quot;*.py&quot;</span><span class="p">))</span>
<span class="go">[PosixPath(&#39;build/lib/pathlib.py&#39;),</span>
<span class="go"> PosixPath(&#39;docs/conf.py&#39;),</span>
<span class="go"> PosixPath(&#39;pathlib.py&#39;),</span>
<span class="go"> PosixPath(&#39;setup.py&#39;),</span>
<span class="go"> PosixPath(&#39;test_pathlib.py&#39;)]</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.rmdir">
<tt class="descclassname">Path.</tt><tt class="descname">rmdir</tt><big>(</big><big>)</big><a class="headerlink" href="#pathlib.Path.rmdir" title="Permalink to this definition"></a></dt>
<dd><p>Remove this directory.  The directory must be empty.</p>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.symlink_to">
<tt class="descclassname">Path.</tt><tt class="descname">symlink_to</tt><big>(</big><em>target</em>, <em>target_is_directory=False</em><big>)</big><a class="headerlink" href="#pathlib.Path.symlink_to" title="Permalink to this definition"></a></dt>
<dd><p>Make this path a symbolic link to <em>target</em>.  Under Windows,
<em>target_is_directory</em> must be true (default <tt class="docutils literal"><span class="pre">False</span></tt>) if the link&#8217;s target
is a directory.  Under POSIX, <em>target_is_directory</em>&#8216;s value is ignored.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">p</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="s">&#39;mylink&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">symlink_to</span><span class="p">(</span><span class="s">&#39;setup.py&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">resolve</span><span class="p">()</span>
<span class="go">PosixPath(&#39;/home/antoine/pathlib/setup.py&#39;)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">stat</span><span class="p">()</span><span class="o">.</span><span class="n">st_size</span>
<span class="go">956</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">p</span><span class="o">.</span><span class="n">lstat</span><span class="p">()</span><span class="o">.</span><span class="n">st_size</span>
<span class="go">8</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The order of arguments (link, target) is the reverse
of <tt class="xref py py-func docutils literal"><span class="pre">os.symlink()</span></tt>&#8216;s.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.touch">
<tt class="descclassname">Path.</tt><tt class="descname">touch</tt><big>(</big><em>mode=0o777</em>, <em>exist_ok=True</em><big>)</big><a class="headerlink" href="#pathlib.Path.touch" title="Permalink to this definition"></a></dt>
<dd><p>Create a file at this given path.  If <em>mode</em> is given, it is combined
with the process&#8217; <tt class="docutils literal"><span class="pre">umask</span></tt> value to determine the file mode and access
flags.  If the file already exists, the function succeeds if <em>exist_ok</em>
is true (and its modification time is updated to the current time),
otherwise <tt class="xref py py-exc docutils literal"><span class="pre">OSError</span></tt> is raised.</p>
</dd></dl>

<dl class="method">
<dt id="pathlib.Path.unlink">
<tt class="descclassname">Path.</tt><tt class="descname">unlink</tt><big>(</big><big>)</big><a class="headerlink" href="#pathlib.Path.unlink" title="Permalink to this definition"></a></dt>
<dd><p>Remove this file or symbolic link.  If the path points to a directory,
use <a class="reference internal" href="#pathlib.Path.rmdir" title="pathlib.Path.rmdir"><tt class="xref py py-func docutils literal"><span class="pre">Path.rmdir()</span></tt></a> instead.</p>
</dd></dl>

</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="#">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">pathlib</a><ul>
<li><a class="reference internal" href="#download">Download</a></li>
<li><a class="reference internal" href="#high-level-view">High-level view</a></li>
<li><a class="reference internal" href="#basic-use">Basic use</a></li>
<li><a class="reference internal" href="#pure-paths">Pure paths</a><ul>
<li><a class="reference internal" href="#general-properties">General properties</a></li>
<li><a class="reference internal" href="#operators">Operators</a></li>
<li><a class="reference internal" href="#accessing-individual-parts">Accessing individual parts</a></li>
<li><a class="reference internal" href="#methods-and-properties">Methods and properties</a></li>
</ul>
</li>
<li><a class="reference internal" href="#concrete-paths">Concrete paths</a><ul>
<li><a class="reference internal" href="#methods">Methods</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/index.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<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><a href="#">pathlib 1.0.1 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, Antoine Pitrou.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3.
    </div>
  </body>
</html>