Op 2005-01-12, Jeff Shannon schreef [EMAIL PROTECTED]:
Torsten Mohr wrote:
I still wonder why a concept like references was not
implemented in Python. I think it is (even if small)
an overhead to wrap an object in a list or a dictionary.
Because Python uses a fundamentally different
Antoon Pardon wrote:
Op 2005-01-12, Jeff Shannon schreef [EMAIL PROTECTED]:
It's also rather less necessary to use references in Python than it is
in C et. al.
You use nothing but references in Python, that is the reason why
if you assign a mutable to a new name and modify the object through
Jeff Shannon [EMAIL PROTECTED] wrote:
Because Python uses a fundamentally different concept for variable
names than C/C++/Java (and most other static languages). In those
languages, variables can be passed by value or by reference; neither
term really applies in Python. (Or, if you
Hi,
Could you give us a more concrete use case? My suspicion is that
anything complicated enough to be passed to a method to be modified will
probably be more than a simple int, float, str or tuple... In which
case, it will probably have methods to allow you to update it...
yes, to be more
Torsten Mohr wrote:
But i think my understanding was wrong (though it is not yet
clear). If i hand over a large string to a function and the
function had the possibility to change it, wouldn't that mean
that it is necessary to hand over a _copy_ of the string?
Else, how could it be immutable?
Torsten Mohr wrote:
Hi,
Could you give us a more concrete use case? My suspicion is that
anything complicated enough to be passed to a method to be modified will
probably be more than a simple int, float, str or tuple... In which
case, it will probably have methods to allow you to update
Hi,
thank you all for your explanations.
That's really great and helps me a lot.
Thanks,
Torsten.
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
thank you all for your explanations.
I still wonder why a concept like references was not
implemented in Python. I think it is (even if small)
an overhead to wrap an object in a list or a dictionary.
Isn't it possible to extend Python in a way to use
real references? Or isn't that
Torsten Mohr wrote:
I still wonder why a concept like references was not
implemented in Python. I think it is (even if small)
an overhead to wrap an object in a list or a dictionary.
Because Python uses a fundamentally different concept for variable
names than C/C++/Java (and most other static
Torsten Mohr [EMAIL PROTECTED] wrote:
...
I still wonder why a concept like references was not
implemented in Python. I think it is (even if small)
an overhead to wrap an object in a list or a dictionary.
Isn't it possible to extend Python in a way to use
real references? Or isn't that
Jeff Shannon wrote:
Torsten Mohr wrote:
I still wonder why a concept like references was not
implemented in Python. I think it is (even if small)
an overhead to wrap an object in a list or a dictionary.
Because Python uses a fundamentally different concept for variable names
than C/C++/Java (and
Torsten Mohr wrote:
I still wonder why a concept like references was not
implemented in Python. I think it is (even if small)
an overhead to wrap an object in a list or a dictionary.
Isn't it possible to extend Python in a way to use
real references? Or isn't that regarded as necessary?
IMHO
Torsten Mohr schrieb:
i'd like to pass a reference or a pointer to an object
to a function. The function should then change the
object and the changes should be visible in the calling
function.
[..]
is something like this possible in python?
Yes, wrap it in a container, e.g. a list or an object.
Torsten Mohr wrote:
Hi,
i'd like to pass a reference or a pointer to an object
to a function. The function should then change the
object and the changes should be visible in the calling
function.
There are two possible meanings of change the object in Python. One
of them will just work for your
Hi,
i'd like to pass a reference or a pointer to an object
to a function. The function should then change the
object and the changes should be visible in the calling
function.
In perl this would be something like:
sub func {
$ref = shift;
$$ref += 123; # change
}
$a = 1;
func(\$a);
is
Torsten Mohr [EMAIL PROTECTED] writes:
i'd like to pass a reference or a pointer to an object
to a function. The function should then change the
object and the changes should be visible in the calling
function.
Normally you would pass a class instance or boxed object, and let the
function
16 matches
Mail list logo