Pass by reference vs value

Categories: PHP

All parameters (arguments) in the Python language are passed by reference. It means if you change what a parameter refers to within a function, the change also reflects back in the calling function. For example −


#!/usr/bin/python


# Function definition is here

def changeme( mylist ):

   "This changes a passed list into this function"

   mylist.append([1,2,3,4]);

   print "Values inside the function: ", mylist

   return


# Now you can call changeme function

mylist = [10,20,30];

changeme( mylist );

print "Values outside the function: ", mylist

Top articles
How to check version of php Published at:- Definition and Type of Python Comment Published at:- Pass by reference vs value Published at:- Python - Network Programming Published at:- PHP Installation on Mac OS X with Apache Published at:- PHP Installation on Windows XP 2000 and XP with IIS Published at:- PHP Installation on Windows XP 2000 & XP with Apache Published at:- PHP MCQ Quiz Question with Answer Published at:- PHP MCQ Quiz Question with Answer (set 2) Published at:- 5 Laravel Development Tools Developers Must Use Published at:- PHP and its use Published at:-
R4Rin Team
The content on R4Rin.com website is created by expert teams.