Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: eryk sun Newsgroups: comp.lang.python Subject: Re: extending PATH on Windows? Date: Fri, 19 Feb 2016 12:07:24 -0600 Lines: 28 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de KR5cepCjyTWuBMaPm1pHjQhmLOOBw13gZahouhhkR/MQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'received:209.85.223': 0.03; 'url:msdn': 0.07; 'subject:Windows': 0.09; '[1]:': 0.09; '[2]:': 0.09; 'def': 0.13; 'thu,': 0.15; '2016': 0.16; 'node,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'registry': 0.16; 'wrote:': 0.16; 'try:': 0.18; 'cc:2**0': 0.20; 'parameter': 0.22; 'simpler': 0.22; 'am,': 0.23; 'feb': 0.23; 'header:In-Reply- To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; '[2]': 0.27; 'values': 0.28; 'similar': 0.33; 'except': 0.34; 'received:google.com': 0.35; 'but': 0.36; 'should': 0.36; 'received:209.85': 0.36; 'data.': 0.36; 'url:library': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'data': 0.39; 'to:addr:python.org': 0.40; 'still': 0.40; 'more': 0.63; 'different': 0.63; 'skip:w 30': 0.64; 'url:en-us': 0.72; 'skip:w 60': 0.84; 'streams': 0.84; 'studying': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=cxpJ4q78b0/II8fSIp8MP3mw/QESeGUpqPfmgI0u5ac=; b=DyyONpEW9zmGHfoUWwZrLBcvZQdwAHgSvzm4pV03/SUKowIXV3aHXB0EnkqLT5rsKo B1jXppPGdPlzs5U4StGwKCLLXbKiTpcMasxiLMpStKgwlM1YK269CebnFupEyKyNzXMZ yTOgmL/fffaLWUDZKYnIUf/Gwq3GmaMXNAhABWEzyWDUXctSHaLz4vk2lfHNRRRWEtY0 V9bXddB+w/FjgAEhcEQQJ19KFMCwf5KHKOz/22SxWCF4ModM6vkHtUbA3OMKd7bcw1Zw YdVcd8KuAgdOSb3JJXqtOAD9GDU+XRe1PEpwE7dpDnHuzubFb1JyH9ZPDmVXO82BDlf3 3fUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=cxpJ4q78b0/II8fSIp8MP3mw/QESeGUpqPfmgI0u5ac=; b=REuavrWztAu5KVmQIjctLlLno/e6p8d6PlT2/PIMFbXZLUrO6pRufeFlTWDoqsG9z6 VlTq1TbdWUNr/eO25NfqVmbuZVhDtf/OQSlND1TuvUC5pDw02j2DEGDkDreraYPdRhWZ h/P6B6SRzvFi4tKh6c//4tMi+ngKQBdvqvwbTcW3/2jBl8NrBPblCKSC/sz9AZfGEeQr z7Q3NU5m3ChfKCtHPui+EmyZl2KeX1g4/S8yt6Grgab+QeaHxlStrA0qxUFoRE1jIS8+ EVGoYzryhwMu5aiWVZ54DU/7VgDQgcg1TiUNJvjH1l/oxITSMWg4FVnwHeROy/coxo4r gfOA== X-Gm-Message-State: AG10YOTpzKeRdaBrsBv+auUTnqn71tAuimXDcQ3BxKN0bNP6XN2sBZcfwSpCMwIRummNN1XW7YvhxXghF4scqQ== X-Received: by 10.107.10.158 with SMTP id 30mr15464675iok.73.1455905284217; Fri, 19 Feb 2016 10:08:04 -0800 (PST) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:103211 On Thu, Feb 18, 2016 at 10:55 AM, Ulli Horlacher wrote: > Ulli Horlacher wrote: > >> > but simpler still and more reliable to just call QueryValueEx. >> >> I find it more complicated. > > I have now (after long studying docs and examples):: > > def get_winreg(key,subkey): > try: > rkey = winreg.OpenKey(winreg.HKEY_CURRENT_USER,key,0,winreg.KEY_READ) > rvalue,rtype = winreg.QueryValueEx(rkey,subkey) > winreg.CloseKey(rkey) > except WindowsError: > rvalue,rtype = None,None > return rvalue The 2nd parameter should be named "value_name", not "subkey". A registry key is similar to an NTFS file-system node, and values are similar to NTFS $DATA streams [1], but with different types of data [2] other than just REG_BINARY, to make it easier to store structured configuration data. [1]: https://msdn.microsoft.com/en-us/library/aa364404 [2]: https://msdn.microsoft.com/en-us/library/ms724884