[Tutor] gnupg within a for loop
Adam Gold
awg1 at gmx.com
Mon Jun 2 02:21:45 CEST 2014
On 01/06/14 18:28, Danny Yoo wrote:
> Hi Adam,
>
> Ah; I've seen this before. Make sure the file name is either relative
> to current working directory, or make the file name absolute. What's
> happening is that os.listdir() is giving you file names that are
> relative to the base directory you've passed it, but open() doesn't
> know about the base directory.
>
> You can use os.path.join() to create such paths:
>
> https://docs.python.org/2/library/os.path.html#os.path.join
>
Thanks Danny, that was spot on. I actually used os.chdir to change to
the base directory (which I assigned to a variable) just before the open
statement. I don't know if that's 'pythonically' correct but it seemed
like a simple way to do it. Again, thank you for helping me fix this.
More information about the Tutor
mailing list