Re: Newbie question about string(passing by ref)

2007-05-30 Thread James T. Dennis
Duncan Booth <[EMAIL PROTECTED]> wrote: > lazy <[EMAIL PROTECTED]> wrote: >> I want to pass a string by reference. I understand that strings are >> immutable, but Im not >> going to change the string in the function, just to aviod the overhead >> of copying(when pass-by-value) because the >> strin

Re: Newbie question about string(passing by ref)

2007-05-30 Thread James T. Dennis
Steven D'Aprano <[EMAIL PROTECTED]> wrote: ... > Python does NOT support pass by reference. Nor does it do pass by value. > Both of those models might describe what other languages do, but they > don't describe what Python does. > Python's passing model is different from both pass by reference

Re: Newbie question about string(passing by ref)

2007-05-11 Thread Steven D'Aprano
On Thu, 10 May 2007 14:53:46 -0700, Gary Herron wrote: > Strings *are* passed by reference *always*. There is no copy and no > overhead. Efficiency is not based on length. Since the string is > immutable, nothing you do inside the function can change the string > outside the function. Python d

Re: Newbie question about string(passing by ref)

2007-05-11 Thread Duncan Booth
lazy <[EMAIL PROTECTED]> wrote: > I want to pass a string by reference. I understand that strings are > immutable, but Im not > going to change the string in the function, just to aviod the overhead > of copying(when pass-by-value) because the > strings are long and this function will be called ov

Re: Newbie question about string(passing by ref)

2007-05-10 Thread Adam Atlas
On May 10, 6:19 pm, lazy <[EMAIL PROTECTED]> wrote: > So, just to make sure even if I return a value, there is no copy done. > Is it correct? > For eg: > > def blah: >long_str="" >return long_str > > my_str=blah() <=== So here there is no copy done but, my_str points to > the same memor

Re: Newbie question about string(passing by ref)

2007-05-10 Thread lazy
Thanks all. > the function you pass it to assigns some other value to the variable, > that's all it's doing: reassigning a local name to point to somewhere > else in memory. So, just to make sure even if I return a value, there is no copy done. Is it correct? For eg: def blah: long_str=""

Re: Newbie question about string(passing by ref)

2007-05-10 Thread Adam Atlas
On May 10, 5:47 pm, Adam Atlas <[EMAIL PROTECTED]> wrote: > On May 10, 5:43 pm, lazy <[EMAIL PROTECTED]> wrote: > > > I want to pass a string by reference. > > Don't worry, all function parameters in Python are passed by reference. Actually, just to clarify a little bit if you're understanding "pa

Re: Newbie question about string(passing by ref)

2007-05-10 Thread Bruno Desthuilliers
lazy a écrit : > Hi, > > I want to pass a string by reference. I understand that strings are > immutable, but Im not > going to change the string in the function, just to aviod the overhead > of copying(when pass-by-value) because the > strings are long and this function will be called over and ov

Re: Newbie question about string(passing by ref)

2007-05-10 Thread Gary Herron
lazy wrote: > Hi, > > I want to pass a string by reference. I understand that strings are > immutable, but Im not > going to change the string in the function, You're confused here. "Immutable" means it *cannot* be changed, so your decision to not change the string is not really your decision at

Re: Newbie question about string(passing by ref)

2007-05-10 Thread Adam Atlas
On May 10, 5:43 pm, lazy <[EMAIL PROTECTED]> wrote: > I want to pass a string by reference. Don't worry, all function parameters in Python are passed by reference. -- http://mail.python.org/mailman/listinfo/python-list

Newbie question about string(passing by ref)

2007-05-10 Thread lazy
Hi, I want to pass a string by reference. I understand that strings are immutable, but Im not going to change the string in the function, just to aviod the overhead of copying(when pass-by-value) because the strings are long and this function will be called over and over again. I initially thought