Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #10596
| Date | 2011-07-30 11:39 -0700 |
|---|---|
| From | Ethan Furman <ethan@stoneleaf.us> |
| Subject | Re: Windows: setting title of console window |
| References | <4E343E1C.90807@stoneleaf.us> <CAPTjJmr3WUGRAEeqjt+oB5cs+KKD5+U9ahgru4r-+S+2T03vSw@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1669.1312051213.1164.python-list@python.org> (permalink) |
Chris Angelico wrote: > 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? Well, you /could/ have followed the link and read the explanation there... ;) However, here it is again: How it works: since the sys.argv object does yet exist, I create an object and assign it to sys.argv; then, when Python assigns the actual argv to sys.argv, my object is tossed, and the __del__ method is called; the __del__ method is then able to access the real argv and set the title bar accordingly. I put the sleep in just to avoid any possible race conditions, but I'm not sure it's necessary. If you don't want to see all the command-line args, you can pre-process command any way you like. ~Ethan~
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Windows: setting title of console window Ethan Furman <ethan@stoneleaf.us> - 2011-07-30 11:39 -0700
csiph-web