with block for multiple files

Yingjie Lan lanyjie at yahoo.com
Mon Nov 1 01:03:52 EDT 2010


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


      



More information about the Python-list mailing list