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


Groups > comp.lang.python > #70944 > unrolled thread

Re: Pass variable by reference

Started byGary Herron <gary.herron@islandtraining.com>
First post2014-05-05 21:42 -0700
Last post2014-05-05 21:42 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Pass variable by reference Gary Herron <gary.herron@islandtraining.com> - 2014-05-05 21:42 -0700

#70944 — Re: Pass variable by reference

FromGary Herron <gary.herron@islandtraining.com>
Date2014-05-05 21:42 -0700
SubjectRe: Pass variable by reference
Message-ID<mailman.9692.1399351656.18130.python-list@python.org>

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

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
>
>

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web