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


Groups > comp.lang.python > #70941

Pass variable by reference

From Satish Muthali <satish.muthali@gmail.com>
Subject Pass variable by reference
Date 2014-05-05 17:39 -0700
Newsgroups comp.lang.python
Message-ID <mailman.9690.1399348396.18130.python-list@python.org> (permalink)

Show all headers | 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