Skip to content

Commit 5cc646c

Browse files
committed
Updated With_As and Added iamge dir
1 parent 581da4c commit 5cc646c

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

README.md renamed to README.md~

File renamed without changes.

With_As.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
## With As
22
```python
3-
With the "With" statement, you get better syntax and exceptions handling. The with statement simplifies exception handling by encapsulating common preparation and cleanup tasks.In addition, it will automatically close the file. The with statement provides a way for ensuring that a clean-up is always used.The lines after as can be used as an object to refer that.Without the with statement, we would write something like this:
3+
With the "With" statement, you get better syntax and exceptions handling.
4+
The with statement simplifies exception handling by encapsulating common preparation and cleanup tasks.
5+
In addition, it will automatically close the file.
6+
The with statement provides a way for ensuring that a clean-up is always used.
7+
The lines after as can be used as an object to refer that.Without the with statement,
8+
we would write something like this:
49

510
file = open("hello.txt")
611
data = file.read()
@@ -17,9 +22,11 @@ with open("hello.txt") as inFile: # Use file to refer to the file object
1722

1823
Here we did not write separate close statement as it is handled by with.
1924
```
20-
![Output](/WA1.png)
25+
![Output](/images/WA1.png)
26+
```
2127
Above is the file hello.txt
22-
![Code](/WA2.png)
28+
```
29+
![Code](/images/WA2.png)
2330
```python
2431
Thus we can see that when we use “with” statement there is no need of separate close statement.
2532
With more than one item, the context managers are processed as if multiple with statements were nested:

WA1.png renamed to images/WA1.png

File renamed without changes.

WA2.png renamed to images/WA2.png

File renamed without changes.

0 commit comments

Comments
 (0)