@@ -30,7 +30,7 @@ Another difference is that Windows paths are written with backslashes (\). As
3030macOS and Linux uses forward slashes (/). To make python work on all OS-es, you
3131will need to handle both cases, which will be shown further down.
3232
33- A helpful function is *os.path.join()*, it will return a string with a file path
33+ A helpful function is ** os.path.join()* *, it will return a string with a file path
3434using the correct path seperators
3535
3636```python
@@ -47,8 +47,8 @@ Follow along with the Python interactive shell. You may or may not get the same
4747output. Do not worry, we are more concerned with you trying out the functions
4848so you can see what they do.
4949
50- *os.getcwd()* - gets current working directory
51- *os.chdir(path)* - changes the directory
50+ ** os.getcwd()* * - gets current working directory
51+ ** os.chdir(path)* * - changes the directory
5252
5353```python
5454 >> import os
@@ -75,7 +75,7 @@ is the relative path. We can try this out in the windows command line.
7575 .. (dot-dot) for parent folder
7676
7777### Creating New Folders
78- Use *os.makedirs(path)* to create a folder
78+ Use ** os.makedirs(path)* * to create a folder
7979
8080## The os.path Module
8181Whenever we are working with paths, we will be using the os.path module. To
@@ -84,29 +84,29 @@ additional functions that can help us. Try to follow along with the Python
8484interactive shell
8585
8686### Handling Abssolute and Relative path
87- *os.path.abspath(path)* - returns a string with the absolute path of the
87+ ** os.path.abspath(path)* * - returns a string with the absolute path of the
8888 argument
8989```python
9090 >> os.path.abspath('.')
9191```
92- *os.path.isabs(path)* - returns True if argument is an absolute path
92+ ** os.path.isabs(path)* * - returns True if argument is an absolute path
9393```python
9494 >> os.path.isabs('.') # Why is this sometimes false?
9595 False
9696 >> os.path.isabs(os.path.abspath('.')) # Why is this true?
9797 True
9898```
99- *os.path.relpath(path, start) - returns a string of a relative path from
99+ ** os.path.relpath(path, start)** - returns a string of a relative path from
100100the start to path. If a start is not given, the current working directory
101101is used
102102```python
103103 >> os.path.relpath('C:\\Windows', 'C:\\')
104104 'Windows'
105105```
106106
107- *os.path.dirname(path)* will return a string of everything that comes before
107+ ** os.path.dirname(path)* * will return a string of everything that comes before
108108 the last slash
109- *os.path.basename(path)* will return a string of everything that comes after
109+ ** os.path.basename(path)* * will return a string of everything that comes after
110110 the last slash
111111```python
112112 >> path = 'C:\\Windows\\System32\\calc.exe'
@@ -116,15 +116,15 @@ is used
116116 'C:\\Windows\\System32'
117117```
118118
119- *os.path.split(path)* takes a path and returns a tuple of the base + dirname
119+ ** os.path.split(path)* * takes a path and returns a tuple of the base + dirname
120120```python
121121 >> path = 'C:\\Windows\\System32\\calc.exe'
122122 >> os.path.split(path)
123123 ('C:\\Windows\\System32', 'calc.exe')
124124```
125125# Finding File Sizes and Folder contents
126- *os.path.getsize(path)* returns the size in bytes of the file
127- *os.listdir(path)* returns a list of strings for each file in the path
126+ ** os.path.getsize(path)* * returns the size in bytes of the file
127+ ** os.listdir(path)* * returns a list of strings for each file in the path
128128```python
129129>> totalSize = 0
130130>> # What does this for-loop do?
0 commit comments