Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #10596

Re: Windows: setting title of console window

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!news2.arglkargh.de!news.wiretrip.org!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ethan@stoneleaf.us>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'assign': 0.04; 'imports': 0.07; 'snippet': 0.07; 'python': 0.08; 'args,': 0.09; 'command- line': 0.09; 'executed': 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; '~ethan~': 0.09; 'wrote:': 0.15; 'assigns': 0.16; 'destructor': 0.16; 'explanation': 0.16; 'overwriting': 0.16; 'set,': 0.16; 'there...': 0.16; 'case.': 0.16; 'cc:addr:python-list': 0.16; 'organize': 0.19; 'command': 0.19; 'subject:Windows': 0.19; 'cc:2**0': 0.21; 'cc:no real name:2**0': 0.22; 'header:In-Reply- To:1': 0.22; 'exist,': 0.23; 'subsequently': 0.23; 'code': 0.24; "i'm": 0.27; 'accordingly.': 0.29; 'affected': 0.29; 'object': 0.30; 'cc:addr:python.org': 0.30; 'fact': 0.30; 'sleep': 0.30; 'yet': 0.30; 'this.': 0.31; 'chris': 0.32; 'like.': 0.32; 'necessary.': 0.32; 'does': 0.32; 'actually': 0.33; 'header:User- Agent:1': 0.34; 'however,': 0.34; 'actual': 0.35; 'but': 0.37; 'subject:: ': 0.38; 'something': 0.38; 'put': 0.38; 'sense': 0.40; 'link': 0.63; 'received:websitewelcome.com': 0.65; 'here': 0.66; 'received:184': 0.67; 'afraid': 0.68; 'race': 0.73; 'received:67.18.82': 0.84; 'received:67.18.82.12': 0.84; 'conditions,': 0.93
Date Sat, 30 Jul 2011 11:39:07 -0700
From Ethan Furman <ethan@stoneleaf.us>
User-Agent Thunderbird 2.0.0.24 (Windows/20100228)
MIME-Version 1.0
To Chris Angelico <rosuav@gmail.com>
Subject Re: Windows: setting title of console window
References <4E343E1C.90807@stoneleaf.us> <CAPTjJmr3WUGRAEeqjt+oB5cs+KKD5+U9ahgru4r-+S+2T03vSw@mail.gmail.com>
In-Reply-To <CAPTjJmr3WUGRAEeqjt+oB5cs+KKD5+U9ahgru4r-+S+2T03vSw@mail.gmail.com>
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]:3149
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1669.1312051213.1164.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1312051213 news.xs4all.nl 23978 [2001:888:2000:d::a6]:36635
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:10596

Show key headers only | View raw


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


Thread

Re: Windows: setting title of console window Ethan Furman <ethan@stoneleaf.us> - 2011-07-30 11:39 -0700

csiph-web