1 |
Am 27.11.2013 22:20, schrieb Mike Frysinger: |
2 |
> On Wednesday 27 November 2013 05:31:17 SebastianLuther@×××.de |
3 |
> wrote: |
4 |
>> + if options.write_timestamp: + timestamp_path = |
5 |
>> os.path.join(repo_path, "metadata", "timestamp.chk") + try: + |
6 |
>> timestampfile = open(timestamp_path, "w") + try: + |
7 |
>> timestampfile.write( + time.strftime("%a, %d %b %Y %H:%M:%S |
8 |
>> +0000", |
9 |
> time.gmtime())) |
10 |
>> + timestampfile.write("\n") + finally: + |
11 |
>> timestampfile.close() |
12 |
> |
13 |
> use a with block, and merge those writes |
14 |
> |
15 |
> with open(timestamp_path, 'w') as f: f.write(time.strftime('%a, %d |
16 |
> %b %Y %H:%M:%S +0000\n', time.gmtime())) -mike |
17 |
> |
18 |
|
19 |
What if the f.write raises an exception? |