Windows: setting title of console window

Chris Angelico rosuav at gmail.com
Sat Jul 30 13:34:48 EDT 2011


On Sat, Jul 30, 2011 at 6:23 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
> 8<-- sitecustomize.py ---------------------------------
> class SetTitle(object):
>    def __del__(self):
>        command = ' '.join(sys.argv)
>
> sys.argv = SetTitle()

I'm afraid I don't understand this. Why create an object and do the
work in the destructor? When will the destructor be called? Will you
subsequently be overwriting sys.argv with the actual arguments?

This code snippet makes excellent sense if and only if it's executed
before sys.argv gets set to something meaningful. I'm just not
following how you organize for this to be the case. Is
sitecustomize.py executed before sys.argv is set, and is this affected
by the fact that it actually imports sys?

ChrisA



More information about the Python-list mailing list