差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
| python:pathlib [2020/03/31 02:31] – [glob.iglob() の実装] ともやん | python:pathlib [2023/05/27 09:00] (現在) – [glob.iglob() の実装] ともやん | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| - | < | + | ====== pathlib, glob.iglob(), os.walk() |
| - | < | + | |
| - | #mincode pre { | + | |
| - | /*height: 300px;*/ | + | |
| - | overflow: scroll; | + | |
| - | overflow-x: hidden; | + | |
| - | font-size: 10px; | + | |
| - | } | + | |
| - | # | + | |
| - | height: 400px; | + | |
| - | overflow: scroll; | + | |
| - | overflow-x: hidden; | + | |
| - | font-size: 10px; | + | |
| - | } | + | |
| - | #mintbl table { | + | |
| - | font-size: 12px; | + | |
| - | } | + | |
| - | .dokuwiki .plugin_wrap table { | + | |
| - | width: auto; | + | |
| - | } | + | |
| - | #result pre { | + | |
| - | /*height: 300px;*/ | + | |
| - | overflow: scroll; | + | |
| - | overflow-x: hidden; | + | |
| - | font-size: 10px; | + | |
| - | } | + | |
| - | </ | + | |
| - | </ | + | |
| - | ====== pathlib, glob, os ====== | + | |
| ===== os.walk() の実装 ===== | ===== os.walk() の実装 ===== | ||
| - | **os.walk(top, | + | < |
| ===== glob.iglob() の実装 ===== | ===== glob.iglob() の実装 ===== | ||
| - | **glob.iglob(pathname, | + | < |
| - | **os.scandir(path=' | + | < |
| - | **fnmatch.filter(names, | + | ここで注意が必要なのは、 **pattern** は **__Unix Shell Style__** のパターンであって正規表現は利用できない。\\ |
| + | < | ||
| \\ | \\ | ||
| **OK パターン**\\ | **OK パターン**\\ | ||
| 行 50: | 行 23: | ||
| </ | </ | ||
| - | < | + | <WRAP mincode_long> |
| <code python python38/ | <code python python38/ | ||
| """ | """ | ||
| 行 229: | 行 202: | ||
| ===== os.scandir() の実装 ===== | ===== os.scandir() の実装 ===== | ||
| - | < | + | [[https:// |
| + | < | ||
| + | Note On Unix-based systems, scandir() uses the system’s opendir() and readdir() functions. On Windows, it uses the Win32 FindFirstFileW and FindNextFileW functions.\\ | ||
| + | \\ | ||
| + | ノート(翻訳) Unix ベースのシステムでは、scandir() はシステムの opendir() 関数と readdir() 関数を使用します。 Windows では、Win32 FindFirstFileW 関数と FindNextFileW 関数を使用します。 | ||
| + | </ | ||
| + | <WRAP mincode_long> | ||
| <code c cpython/ | <code c cpython/ | ||
| /*[clinic input] | /*[clinic input] | ||
| os.scandir | os.scandir | ||
| + | |||
| path : path_t(nullable=True, | path : path_t(nullable=True, | ||
| + | |||
| Return an iterator of DirEntry objects for given path. | Return an iterator of DirEntry objects for given path. | ||
| + | |||
| path can be specified as either str, bytes, or a path-like object. | path can be specified as either str, bytes, or a path-like object. | ||
| is bytes, the names of yielded DirEntry objects will also be bytes; in | is bytes, the names of yielded DirEntry objects will also be bytes; in | ||
| all other circumstances they will be str. | all other circumstances they will be str. | ||
| + | |||
| If path is None, uses the path=' | If path is None, uses the path=' | ||
| [clinic start generated code]*/ | [clinic start generated code]*/ | ||
| 行 340: | 行 323: | ||
| </ | </ | ||
| </ | </ | ||
| - | [[https:// | + | [[https:// |
| ===== パフォーマンス比較 ===== | ===== パフォーマンス比較 ===== | ||
| 行 407: | 行 390: | ||
| [[https:// | [[https:// | ||
| [[https:// | [[https:// | ||
| + | [[https:// | ||