7
User
Recs.
Recs.
1
Updates
Last
Updated
Updated
Activity
The 'with' statement allows a user to easily handle resources that require opening and closing (implementing enter and exit methods) by creating a scope in which the resource is available. This ensures the resource is handled properly when execution falls out of this scope, and saving the user from having to write biolerplate exception handling code.
with open('foo.txt', 'w') as f:
f.write('hello!')
Specs
Pros
Know any positive aspects of this option?
Cons
Know any negative aspects of this option?
Recommendations
'with' Statement
Recommended 8 years ago
Michael hasn’t added their experience, pros or cons to their recommendation.
'with' Statement
Recommended 8 years ago
Hạns hasn’t added their experience, pros or cons to their recommendation.
'with' Statement
Recommended 11 years ago
CheesySquirrel hasn’t added their experience, pros or cons to their recommendation.
'with' Statement
Recommended 11 years ago
Kyle hasn’t added their experience, pros or cons to their recommendation.
'with' Statement
Recommended 11 years ago
Sathvik hasn’t added their experience, pros or cons to their recommendation.
'with' Statement
Recommended 11 years ago
T-R hasn’t added their experience, pros or cons to their recommendation.
'with' Statement
Recommended 11 years ago
wodow hasn’t added their experience, pros or cons to their recommendation.