Message77406
Hum, there is not fixer for 2to3. But I might be hard to write such
fixer because walk() generates (dirpath, dirnames, filenames) instead
of (dirpath, filenames).
Python2 prototype:
os.path.walk(path, visit, arg) -> None
with visit: callback(arg, dirpath, filenames)
Python3 prototype:
os.walk(top[, topdown=True[, onerror=None[, followlinks=False]]]) ->
generator
with onerror: callback()
the generator produces (dirpath, dirnames, filenames)
Example:
os.path.walk('Lib/xml/', callback, 42)
can be replaced by
for dirpath, dirnames, filenames in os.walk('Lib/xml/'):
callback(42, dirpath, dirnames + filenames)
About the keyword only: +1 (or +2 :-)).
Index: Lib/os.py
===================================================================
--- Lib/os.py (révision 67652)
+++ Lib/os.py (copie de travail)
@@ -192,7 +192,7 @@
__all__.extend(["makedirs", "removedirs", "renames"])
-def walk(top, topdown=True, onerror=None, followlinks=False):
+def walk(top, *, topdown=True, onerror=None, followlinks=False):
"""Directory tree generator.
For each directory in the directory tree rooted at top (including
top |
|
Date |
User |
Action |
Args |
2008-12-09 12:19:38 | vstinner | set | recipients:
+ vstinner, amaury.forgeotdarc, legerf |
2008-12-09 12:19:38 | vstinner | set | messageid: <[email protected]> |
2008-12-09 12:19:38 | vstinner | link | issue4601 messages |
2008-12-09 12:19:37 | vstinner | create | |
|