[Tutor] os.system and/or subprocess.call problem...

Steve Willoughby steve at alchemy.com
Fri Jul 10 19:22:17 CEST 2009

On Fri, Jul 10, 2009 at 12:22:24PM -0500, daychilde at gmail.com wrote:
>         self.filename = 'bsf.ini'
>         self.fullpath = self.thispath + self.filename
>         self.fh = open(self.fullpath, 'w')
>         self.fh.write(self.bsf_ini)
>         self.fh.close
> Which doesn't show where the vars come from, but I am closing the file
> first.

Actually, no, it doesn't.  You forgot the () which are needed to 
actually _call_ the close method on the last line.


is an expression which evaluates to the close method object
belonging to the file object self.fh belonging to the object 
instance in play here.


on the other hand, takes that method and calls it, and evaluates
to whatever that method call returns.

> : When you start the subprocess, is it being started in the directory
> : you think it is?
> Well... I know that when I use os.system to create a directory, it starts in
> cwd, which in this case is /home/isaac/loopy/ -- I create a directory with
> the timestamp as the name, and successfully write out the bsf.ini files into
> subfolders underneath it... so I think I'm confident that, at least when I
> use os.system, it executes in cwd -- but I specific the path to the command,
> so I think that doesn't matter anyway, e.g.:

Ok, that sounds good.

> /home/isaac/bluesky/bluesky
> --inifile=/home/isaac/loopy/[timestamp]/12/bsf.ini
> And I know the above is valid otherwise, as I have put in a print statement
> and copied the actual line I generated and it executed fine... :)
> Thank you for your reply; I appreciate all help I get on this. :)
> -Isaac

Steve Willoughby    |  Using billion-dollar satellites
steve at alchemy.com   |  to hunt for Tupperware.

More information about the Tutor mailing list