with block for multiple files

Y

Yingjie Lan

Hi,

Suppose I am working with two files simultaneously,
it might make sense to do this:

with open('scores.csv'), open('grades.csv', wt) as f,g:
g.write(f.read())

sure, you can do this with nested with-blocks,
but the one above does not seem too complicated,
it is like having a multiple assignment...

Any thoughts?

Another mini-proposal:

Allow the conditions in the if-, elif-, while-, for-, and
with-clauses to span multiple lines without using a backlalsh,
just like when you specify literal lists, tuples, dicts, etc.
across multiple lines (similar to comprehensions too).

My reason is this:
because they all must end with a required colon ':',
so nobody will mistake it.

Just some half-baked ideas, would appreciate
thos who shed light on these issues.

Yingjie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top