passing by refference

Batista, Facundo FBatista at uniFON.com.ar
Tue May 13 11:31:46 EDT 2003


I shouldn't work with references, it's one of the fantastics properties of
Python!!

If you want to return a lot of objects, just return them!!

Example:

Python 2.1.1 (#1, Jan  6 2003, 16:05:24)
[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-110)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> def funct(number):
...     return range(number)
...
>>> values = funct(5)
>>> values
[0, 1, 2, 3, 4]
>>> print values
[0, 1, 2, 3, 4]
>>> print "\n".join([str(val) for val in values])
0
1
2
3
4
>>>

If you feel that you can't, just send one example.

.	Facundo


#- -----Mensaje original-----
#- De: Daan Hoogland [mailto:hoogland at astron.nl]
#- Enviado el: Martes 13 de Mayo de 2003 11:00 AM
#- Para: python-list at python.org
#- Asunto: passing by refference
#- 
#- 
#- is passing by reffence possible in python?
#- 
#- I'd like the following code to print 
#- 1
#- instead of
#- 2
#- 
#- <file name="D.py">
#- def spam(**ni):
#-   ni["egg"] = 1;
#- 
#- bacon = 2
#- spam(egg = bacon)
#- print bacon
#- </file>
#- 
#- the actual construct is going to return several newly 
#- created object, to give a
#- reason why.
#- 
#- -- 
#- http://mail.python.org/mailman/listinfo/python-list
#- 





More information about the Python-list mailing list