Re: reference or pointer to some object?

2005-01-13 Thread Antoon Pardon
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

Re: reference or pointer to some object?

2005-01-13 Thread Jeff Shannon
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

Re: reference or pointer to some object?

2005-01-13 Thread Alex Martelli
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

Re: reference or pointer to some object?

2005-01-13 Thread Torsten Mohr
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

Re: reference or pointer to some object?

2005-01-13 Thread Jeff Shannon
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?

Re: reference or pointer to some object?

2005-01-13 Thread Reinhold Birkenfeld
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

Re: reference or pointer to some object?

2005-01-13 Thread Torsten Mohr
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

Re: reference or pointer to some object?

2005-01-12 Thread Torsten Mohr
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

Re: reference or pointer to some object?

2005-01-12 Thread Jeff Shannon
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

Re: reference or pointer to some object?

2005-01-12 Thread JCM
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

Re: reference or pointer to some object?

2005-01-12 Thread Steven Bethard
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

Re: reference or pointer to some object?

2005-01-12 Thread Steven Bethard
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

Re: reference or pointer to some object?

2005-01-11 Thread Peter Maas
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.

Re: reference or pointer to some object?

2005-01-11 Thread Jeff Shannon
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

reference or pointer to some object?

2005-01-10 Thread Torsten Mohr
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

Re: reference or pointer to some object?

2005-01-10 Thread Paul Rubin
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