Mark Tolonen Mark Tolonen k 22 22 gold badges silver badges bronze badges. Your glob pattern is almost correct. I don't speak R, but this might translate your code: for filename in glob.
Reck 1, 10 10 silver badges 20 20 bronze badges. Alex Alex 1 1 gold badge 6 6 silver badges 20 20 bronze badges. Why a comment is given as an answer. There is no answer. Thats the suggestion you are giving. Reck please suggest a way to turn this comment into an answer. Add some code to make your suggestion as an answer. There is no button as such to turn this comment into an answer or else I would have surely helped you. Carson Carson 2, 1 1 gold badge 19 19 silver badges 28 28 bronze badges.
Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back Featured on Meta. Active Oldest Votes. As of Python 2.
Improve this answer. Sven Marnach Sven Marnach k gold badges silver badges bronze badges. Unfortunately, according to the contextlib. Short answer: Yes, there is ExitStack as of Python 3.
There is no easy way of doing this in any earlier version of Python. Is it possible to have this syntax span multiple lines?
You should probably use backslash line continuation to break at the comma, as recommended by PEP 9. Show 7 more comments. Michael Michael 8, 3 3 gold badges 36 36 silver badges 53 53 bronze badges. You should specify which versions of Python support this syntax. Michael Ohlrogge Michael Ohlrogge 9, 5 5 gold badges 43 43 silver badges 72 72 bronze badges. With this indentation I get: "flake8: continuation line over-indented for visual indent" — Louis M.
LouisM That sounds like something coming from your editor or environment, rather than base python. If it continues to be a problem for you, I'd recommend creating a new question relating to it and giving more detail on your editor and environment. Yes it is definitely my editor, and it is only a warning. What I wanted to emphasize is that your indentation does not comply with PEP8. You should indent the second open with 8 spaces instead of aligning it with the first one.
Yes no problem with that, it might be useful for other people with automatic linters though : — Louis M. Show 1 more comment. Community Bot 1 1 1 silver badge. Let's say you have inFile. FatihAkici FatihAkici 3, 1 1 gold badge 21 21 silver badges 44 44 bronze badges. We are in ; so ancient versions in the past — El Ruso. A friendly reminder to those poo-poohing python 2. So this answer is as of right now still the best overall one IMO.
Unnecessarily nested code lowers readability and is considered a bad practice. ElRuso why is it more pythonic? The operation is performed synchronously and both the files are opened at the same time. By default, the files are opened to support read operations. The following text files are used in the later sections of codes : Steps Needed Steps used to open multiple files together in Python :. Skip to content. Change Language.
Related Articles. Table of Contents. Improve Article. Save Article. Like Article.
0コメント