[Python-Dev] Multiline with statement line continuation
Nick Coghlan
ncoghlan at gmail.com
Sun Aug 17 03:10:00 CEST 2014
More information about the Python-Dev mailing list
Sun Aug 17 03:10:00 CEST 2014
- Previous message: [Python-Dev] Multiline with statement line continuation
- Next message: [Python-Dev] Multiline with statement line continuation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 17 August 2014 07:42, Chris Angelico <rosuav at gmail.com> wrote: > On Sat, Aug 16, 2014 at 10:47 PM, Marko Rauhamaa <marko at pacujo.net> wrote: >> >> You might be able to have it bothways. You could have: >> >> with (open(name) for name in os.listdir("config")) as files: > > But that's not a tuple, it's a generator. Should generators be context > managers? Is anyone seriously suggesting this? I don't think so. Is > this solutions looking for problems? Yes. We have a whole programming language to play with, when "X is hard to read" becomes a problem, it may be time to reach for a better tool. If the context manager line is getting unwieldy, it's often a sign it's time to factor it out to a dedicated helper, or break it up into multiple with statements :) Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-Dev] Multiline with statement line continuation
- Next message: [Python-Dev] Multiline with statement line continuation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list