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


Groups > comp.lang.python > #70941

Pass variable by reference

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <satish.muthali@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.036
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'python.': 0.02; 'example:': 0.03; 'postgresql': 0.07; 'subject:variable': 0.16; 'variable': 0.18; 'trying': 0.19; '(where': 0.19; 'print': 0.22; 'question': 0.24; 'pass': 0.26; 'appreciated.': 0.29; 'extract': 0.31; 'skip:- 30': 0.32; 'running': 0.33; 'received:google.com': 0.35; 'version': 0.36; 'var': 0.36; 'thanks': 0.36; 'example,': 0.37; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'how': 0.40; 'header:Message-Id:1': 0.63; 'charset:windows-1252': 0.65; 'as:': 0.81; 'burning': 0.84; 'skip:/ 30': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:subject:message-id:date:to:mime-version; bh=79ec0xv+9d2bQaMeDuzOUSNM73m2LBRshRPGngxtSPM=; b=eue1UH/UXvn/Lu/8AmCTvELOIuBq6POfy2xHTxBMg1yhkF/mw7QS9v6QxhrrPO/g3/ X0amndphmy90CJXU7zMnLolMGqrHYa+ahEfgauIGNdU0QrMg+dhZJGQsH3HPj1FhslXm Bm5UgR4h1dSpqtnuU5T9a+0lvrV2XDD1bmUcDbqu9pYGuTol2UDttktHbauwRxB3sgUo oe+bcXpiKOR4Tfuj4XwnIUQUK/L/XRxwCSIxnE40lLgenl9UFdfjsmqeciSwarDUdww7 ihqdK/aYDYxXnmwnv//IdrcOjKEqxj4Bo7xBgOwiFReGQZ1xgiFW+x0b2xQt24zWCdQA Wy2Q==
X-Received by 10.66.250.161 with SMTP id zd1mr238873pac.136.1399336787965; Mon, 05 May 2014 17:39:47 -0700 (PDT)
From Satish Muthali <satish.muthali@gmail.com>
Content-Type multipart/alternative; boundary="Apple-Mail=_48C16828-C097-4FD6-9576-401F77D302E6"
Subject Pass variable by reference
Date Mon, 5 May 2014 17:39:44 -0700
To python-list@python.org
Mime-Version 1.0 (Mac OS X Mail 7.2 \(1874\))
X-Mailer Apple Mail (2.1874)
X-Mailman-Approved-At Tue, 06 May 2014 05:53:14 +0200
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.9690.1399348396.18130.python-list@python.org> (permalink)
Lines 63
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1399348396 news.xs4all.nl 2875 [2001:888:2000:d::a6]:50782
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:70941

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

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.

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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Pass variable by reference Satish Muthali <satish.muthali@gmail.com> - 2014-05-05 17:39 -0700
  Re: Pass variable by reference Rustom Mody <rustompmody@gmail.com> - 2014-05-05 21:32 -0700
  Re: Pass variable by reference Steven D'Aprano <steve@pearwood.info> - 2014-05-06 08:18 +0000
    Re: Pass variable by reference Marko Rauhamaa <marko@pacujo.net> - 2014-05-06 12:11 +0300
      Re: Pass variable by reference Chris Angelico <rosuav@gmail.com> - 2014-05-06 19:53 +1000
        Re: Pass variable by reference Marko Rauhamaa <marko@pacujo.net> - 2014-05-06 13:38 +0300
          Re: Pass variable by reference Chris Angelico <rosuav@gmail.com> - 2014-05-06 20:45 +1000

csiph-web