Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'assign': 0.04; 'python': 0.08; 'args,': 0.09; 'command-line': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:gator410.hostgator.com': 0.09; 'subject:setting': 0.09; 'thrown': 0.09; '~ethan~': 0.09; 'wrote:': 0.15; 'assigns': 0.16; 'failed.': 0.16; 'received:gateway01.websitewelcome.com': 0.16; "hasn't": 0.16; 'cc:addr:python-list': 0.16; 'command': 0.19; 'subject:Windows': 0.19; "haven't": 0.21; 'cc:2**0': 0.21; 'cc:no real name:2**0': 0.22; 'header:In-Reply-To:1': 0.22; '(without': 0.23; 'exist,': 0.23; 'runs': 0.23; "i'm": 0.27; 'bit': 0.28; 'accordingly.': 0.29; 'object': 0.30; 'cc:addr:python.org': 0.30; 'exist.': 0.30; 'sleep': 0.30; 'yet': 0.30; 'least': 0.31; 'like.': 0.32; 'necessary.': 0.32; 'does': 0.32; 'done': 0.33; 'header:User-Agent:1': 0.34; "can't": 0.34; 'actual': 0.35; 'bigger': 0.37; 'but': 0.37; 'subject:: ': 0.38; 'put': 0.38; 'run': 0.39; 'did': 0.40; 'where': 0.40; 'received:websitewelcome.com': 0.65; 'received:184': 0.67; 'works,': 0.68; 'soon': 0.73; 'race': 0.73; 'received:69.56': 0.73; 'fish': 0.91; 'immediately,': 0.91; 'conditions,': 0.93 Date: Sat, 30 Jul 2011 17:07:43 -0700 From: Ethan Furman User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: Thomas Jollans Subject: Re: Windows: setting title of console window References: <4E343E1C.90807@stoneleaf.us> <4E344FCB.7030801@stoneleaf.us> <4E3490B8.1050004@jollybox.de> In-Reply-To: <4E3490B8.1050004@jollybox.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: c-67-170-168-84.hsd1.or.comcast.net ([192.168.74.5]) [67.170.168.84]:3264 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1312070931 news.xs4all.nl 23926 [2001:888:2000:d::a6]:45851 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:10606 Thomas Jollans wrote: > On 30/07/11 20:39, Ethan Furman wrote: >> 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. > > Why though? Can't you just call SetConsoleTitle immediately? When you say immediately, when exactly do you mean? I can't call it when sitecustomize first runs because sys.argv does not yet exist. If I call it as soon as __del__ is run (without the sleep) then sometimes it works, but at least once it failed. I haven't done a lot of research into it as it hasn't failed with the bit of sleep thrown in, and I have bigger fish to fry. Now where did I put the tartar sauce? ;) ~Ethan~