as compared to:with open ('test.txt', 'n') as f print(f.mode) #f.close # not required
The first case will automatically exit the file when outside the block. The second case requires instruction. Is there an equivalence for Perl? What would the merits be of a similar approach in Perl?f = open ('test.txt','n') print(f.mode) f.close() # required
In reply to Automatically exiting a file within a block by betmatt
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |