Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2a.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; 'example:': 0.03; 'method.': 0.07; 'postgresql': 0.07; 'mentions': 0.09; 'received:67.192': 0.09; 'received:67.192.241': 0.09; 'received:dfw.emailsrvr.com': 0.09; 'python': 0.11; '*values*': 0.16; 'different,': 0.16; 'subject:variable': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'trying': 0.19; '(where': 0.19; 'passing': 0.19; 'seems': 0.21; 'print': 0.22; 'header:User-Agent:1': 0.23; 'received:emailsrvr.com': 0.24; 'question': 0.24; 'received:(smtp server)': 0.26; 'pass': 0.26; 'values': 0.27; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'appreciated.': 0.29; 'extract': 0.31; 'gary': 0.31; 'skip:- 30': 0.32; 'running': 0.33; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'version': 0.36; 'var': 0.36; 'thanks': 0.36; 'example,': 0.37; 'to:addr:python- list': 0.38; 'issue': 0.38; 'fact': 0.38; 'pm,': 0.38; 'little': 0.38; 'does': 0.39; 'help,': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'how': 0.40; 'even': 0.60; 'most': 0.60; 'such': 0.63; 'more': 0.64; 'different': 0.65; 'here': 0.66; 'as:': 0.81; 'burning': 0.84; 'skip:/ 30': 0.84 X-Virus-Scanned: OK Date: Mon, 05 May 2014 21:42:05 -0700 From: Gary Herron User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Pass variable by reference References: <235C4BFA-9770-481A-9FCF-21C3F036769C@gmail.com> In-Reply-To: <235C4BFA-9770-481A-9FCF-21C3F036769C@gmail.com> Content-Type: multipart/alternative; boundary="------------070202050808050209070906" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 146 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1399351656 news.xs4all.nl 2876 [2001:888:2000:d::a6]:37325 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:70944 This is a multi-part message in MIME format. --------------070202050808050209070906 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 05/05/2014 05:39 PM, Satish Muthali wrote: > Hello experts, > > I have a burning question on how to pass variable by reference in > Python. I understand that the data type has to be mutable. This gets confusing, but in fact the most accurate answer is that Python does not have "variables", so there is no such thing as passing "variables" by reference or any other method. Python *does* have names bound to values, but that's a very different thing. If necessary, you may consider that the *values* are passed by reference. Your question is confused when it mentions "mutable" here -- that's something very different, And your question then goes on to end on an even more confused note with "I want to nuke ..." which seems to have nothing to do with passing values anywhere? Sorry to be of so little help, Gary Herron > > For example, here's the issue I am running in to: > > I am trying to extract the PostgreSQL DB version for example: > > /pgVer = [s.split() for s in os.popen("psql > --version").read().splitlines()]/ > / print pgVer[0]/ > / for i, var in enumerate(pgVer[0]):/ > / if i == len(pgVer[0]) - 1:/ > / pgversion = var/ > / > / > I would now like to pass 'pgversion' (where the value of pgversion is > 9.3.4) by reference, for example: > > I want to nuke /var/lib/postgresql/9.3.4/main/data , however > programatically I want it to be as: /var/lib/postgresql/*/ pgversion>/*/main/data > > Any help is appreciated. > > Thanks > Satish > > --------------070202050808050209070906 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
On 05/05/2014 05:39 PM, Satish Muthali wrote:
Hello experts,

I have a burning question on how to pass variable by reference in Python. I understand that  the data type has to be mutable.

This gets confusing, but in fact the most accurate answer is that Python does not have "variables", so there is no such thing as passing "variables" by reference or any other method.  Python *does* have names bound to values, but that's a very different thing. If necessary, you may consider that the *values* are passed by reference.

Your question is confused when it mentions "mutable" here -- that's something very different,  And your question then goes on to end on an even more confused note with "I want to nuke ..." which seems to have nothing to do with passing values anywhere?

Sorry to be of so little help,
Gary Herron





For example, here’s the issue I am running in to:

I am trying to extract the PostgreSQL DB version for example:

pgVer = [s.split() for s in os.popen("psql --version").read().splitlines()]
    print pgVer[0]
    for i, var in enumerate(pgVer[0]):
   if i == len(pgVer[0]) - 1:
   pgversion = var

I would now like to pass ‘pgversion’ (where the value of pgversion is 9.3.4) by reference, for example:

I want to nuke /var/lib/postgresql/9.3.4/main/data , however programatically I want it to be as:  /var/lib/postgresql/<value of pgversion>/main/data

Any help is appreciated.

Thanks
Satish



--------------070202050808050209070906--