pattern-based string expansion
Justin Sheehy
dworkin at ccs.neu.edu
Sun Apr 16 20:52:01 EDT 2000
sue <smalleys at gte.net> writes:
> I need to generate a (largish) set of strings from a
> pattern, sort of like glob with csh-style expansion.
>
> Given "foo{,bar,baz/[aced]{,x,z}}", generate:
>
> foo
> foobar
> foobaz/a
> foobaz/c
> foobaz/e
> foobaz/d
> foobaz/ax
> foobaz/az
>
> etc.
>
> The manual doesn't seem to have this glob(3) option.
Python has glob, but neither Python's glob nor the glob(3) UNIX
library function does what you describe. Both of them produce all
pathnames that match the given glob, not all possible strings that
could match the given glob.
In fact, if you retain the expressivity of glob, the function you
describe is not practically possible. What should it return if given
the glob "*"?
-Justin
More information about the Python-list
mailing list