"glob" — Unix 形式のパス名のパターン展開
****************************************

**ソースコード:** Lib/glob.py

======================================================================

The "glob" module finds all the pathnames matching a specified pattern
according to the rules used by the Unix shell, although results are
returned in arbitrary order.  No tilde expansion is done, but "*",
"?", and character ranges expressed with "[]" will be correctly
matched.  This is done by using the "os.listdir()" and
"fnmatch.fnmatch()" functions in concert, and not by actually invoking
a subshell.  Note that unlike "fnmatch.fnmatch()", "glob" treats
filenames beginning with a dot (".") as special cases. (For tilde and
shell variable expansion, use "os.path.expanduser()" and
"os.path.expandvars()".)

リテラルにマッチさせるには、メタ文字を括弧に入れてください。例えば、
"'[?]'" は文字 "'?'" にマッチします。

glob.glob(pathname)

   *pathname* (パスの指定を含んだ文字列でなければいけません) にマッチ
   する、空の可能性のあるパス名のリストを返します。*pathname* は
   ("/usr/src/Python-1.5/Makefile" のように) 絶対パスでも、
   ("../../Tools/*/*.gif" のように) 相対パスでもよく、シェル形式のワイ
   ルドカードを含んでいてもかまいません。結果には (シェルと同じく) 壊
   れたシンボリックリンクも含まれます。

glob.iglob(pathname)

   実際には一度にすべてを格納せずに、"glob()" と同じ値を順に生成する *
   イテレーター* を返します。

   バージョン 2.5 で追加.

For example, consider a directory containing only the following files:
"1.gif", "2.txt", and "card.gif".  "glob()" will produce the following
results.  Notice how any leading components of the path are preserved.

   >>> import glob
   >>> glob.glob('./[0-9].*')
   ['./1.gif', './2.txt']
   >>> glob.glob('*.gif')
   ['1.gif', 'card.gif']
   >>> glob.glob('?.gif')
   ['1.gif']

ディレクトリが "." で始まるファイルを含んでいる場合、デフォルトでそれ
らはマッチしません。例えば、 "card.gif" と ".card.gif" を含むディレク
トリを考えてください:

   >>> import glob
   >>> glob.glob('*.gif')
   ['card.gif']
   >>> glob.glob('.c*')
   ['.card.gif']

参考:

  "fnmatch" モジュール
     シェル形式の (パスではない) ファイル名展開
