[EMAIL PROTECTED] wrote:
> Hi!
>
> I would to working with some files. But I have to using a regular expression
> with one of them:
>
> for file in [glob.glob('/etc/env.d/[0-9]*foo'), '/etc/bar']:
>
> glob returns a list so i'm supposed that i would that convert it into a
> string.
glob.glob() returns a list of file paths that match your path spec. You
are embedding this list in another list. The result of
[glob.glob('/etc/env.d/[0-9]*foo'), '/etc/bar']
will be a list something like this:
[ [ '/etc/env.d/123foo', '/etc/env.d/456foo' ], '/etc/bar' ]
Iterating over this list will bind the name 'file' to the entire first
list, then to '/etc/bar'.
The solution is to create a flat list instead of a nested list. Try
for file in glob.glob('/etc/env.d/[0-9]*foo') + ['/etc/bar']:
Kent
PS 'file' is the name of a built-in function, it would be better to
choose a different name for your variable.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor