Newbie question about string(passing by ref)

Adam Atlas adam at atlas.st
Thu May 10 18:30:34 EDT 2007


On May 10, 6:19 pm, lazy <arunm... at gmail.com> 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 memory where long_str was created.

Exactly. As Bruno said, Python does not copy objects unless you
specifically tell it to.




More information about the Python-list mailing list