Reference Variables In Python Like Those In PHP

Terry Reedy tjreedy at udel.edu
Tue Aug 15 10:37:46 EDT 2006


"Chaos" <psnim2000 at gmail.com> wrote in message 
news:1155651471.605912.46640 at m73g2000cwd.googlegroups.com...
> Is It possible to have reference variables like in PHP
> <?php
> $x = 1;
> $y =& $x;
> $y += 1;
> echo $x;
> echo "\n"
> echo $y;
> ?>
>
> This would show
> 2
> 2
> Is this available in python?

No, in the literal meaning of your question.  But..
1. The concept 'reference variable' pertains to PHP's object model, which 
is different from Python's.
2. They are means, not ends.  So a possibly more useful question would be 
along the lines of "In PHP, I do this with a reference variable.  How can I 
accomplish the same goal in Python?"

Terry Jan Reedy






More information about the Python-list mailing list