You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- An absolute path, which always begins with the root folder.
2567
-
- A relative path, which is relative to the program’s current working directory.
2570
+
- An absolute path, which always begins with the root folder
2571
+
- A relative path, which is relative to the program’s current working directory
2568
2572
2569
-
There are also the dot (.) and dot-dot (..) folders. These are not real folders but special names that can be used in a path. A single period (“dot”) for a folder name is shorthand for “this directory.” Two periods (“dot-dot”) means “the parent folder”.
2573
+
There are also the dot (.) and dot-dot (..) folders. These are not real folders but special names that can be used in a path. A single period (“dot”) for a folder name is shorthand for “this directory.” Two periods (“dot-dot”) means “the parent folder.”
2570
2574
2571
2575
[*Return to the Top*](#python-cheatsheet)
2572
2576
@@ -2594,7 +2598,7 @@ True
2594
2598
False
2595
2599
```
2596
2600
2597
-
*You can extract an absolute path with both `os.path`and`pathlib`*
2601
+
You can extract an absolute path with both `os.path`and`pathlib`
2598
2602
2599
2603
Using `os.path` on \*nix:
2600
2604
@@ -2616,7 +2620,7 @@ print(Path('..').resolve())
2616
2620
/home
2617
2621
```
2618
2622
2619
-
You can get a relative path from a starting path to another path:
2623
+
You can get a relative path from a starting path to another path.
2620
2624
2621
2625
Using `os.path` on \*nix:
2622
2626
@@ -2638,6 +2642,8 @@ etc/passwd
2638
2642
2639
2643
### Checking Path Validity
2640
2644
2645
+
Checking if a file/directory exists:
2646
+
2641
2647
Using `os.path` on \*nix:
2642
2648
2643
2649
```python
@@ -2722,6 +2728,8 @@ False
2722
2728
2723
2729
### Finding File Sizes and Folder Contents
2724
2730
2731
+
Getting a file's size in bytes:
2732
+
2725
2733
Using `os.path` on Windows:
2726
2734
2727
2735
```python
@@ -2914,14 +2922,14 @@ The current folder is C:\delicious\walnut\waffles
0 commit comments