Re: [问题] 关于list的append方法

楼主: uranusjr (←這人是超級笨蛋)   2017-07-19 02:51:36
※ 引述《LessonWang (橘白Cat)》之铭言:
→ zerof: pass by reference. 07/18 13:53
→ uranusjr: 跟 C 没有关系吧, 也不是 pass by reference 不要乱教.. 07/18 15:44
→ zerof: http://imgur.com/TDlJMiJ ??? 所以是 by value? 07/18 17:45
→ uranusjr: @zerof: By reference 和 by value 的差异不是这样看的 07/18 21:10
→ uranusjr: 这个议题去 Google 就有一堆资料, 可以试着研究看看 07/18 21:12
→ s860134: 我记得书上是说根据传入参数 mutable/immutable 来分 07/19 02:03
→ s860134: 当然你说最底层的实做是用 C 一定是指标只来只去拉... 07/19 02:04
→ zerof: 认知就是 by ref, 你要不要贴个参考资料说它不是? 07/19 02:06
→ s860134: stackoverflow 986006 也是讨论得乱七八糟XD 07/19 02:21
→ s860134: https://goo.gl/aXGATb 07/19 02:24
啊你的认知就是错的啊, 我就说 Google 就有一堆资料了你都没有在听嘛
https://www.google.com.tw/?q=python+call+by+reference
就看前五个结果好不好
1. https://stackoverflow.com/questions/986006
这个上面也有提到, 直接看 accepted answer (同时也是分数最高)
Arguments are passed by assignment. [...] the parameter passed in is
actually a reference to an object (but the reference is passed by value).
2. https://stackoverflow.com/questions/13299427
[...] while you can't explicitly pass variables by reference in Python [...]
3. http://d.pr/KbZ2AS
Is Python call-by-value or call-by-reference? Neither.
4. http://www.python-course.eu/passing_arguments.php
The authors who call the mechanism call-by-value and those who call it
call-by-reference are stretching the definitions until they fit. Correctly
speaking, Python uses a mechanism, which is known as "Call-by-Object",
sometimes also called "Call by Object Reference" or "Call by Sharing".
5. http://d.pr/GpSU86
Unfortunately, Python is "pass-by-object-reference", of which it is
often said:
"Object references are passed by value."
好啦反正众说纷纭大家都在发明自己的名词
但是上面好像是有个共通点就是所有人都一致同意 call/pass by reference 是错的
大guy4这样
作者: zerof (猫橘毛发呆雕像)   2016-07-18 13:53:00
pass by reference.
楼主: uranusjr (←這人是超級笨蛋)   2016-07-18 15:44:00
跟 C 没有关系吧, 也不是 pass by reference 不要乱教..
作者: zerof (猫橘毛发呆雕像)   2016-07-18 17:45:00
http://imgur.com/TDlJMiJ ??? 所以是 by value?
楼主: uranusjr (←這人是超級笨蛋)   2016-07-18 21:10:00
@zerof: By reference 和 by value 的差异不是这样看的这个议题去 Google 就有一堆资料, 可以试着研究看看
作者: s860134 (s860134)   2016-07-19 02:03:00
我记得书上是说根据传入参数 mutable/immutable 来分当然你说最底层的实做是用 C 一定是指标只来只去拉...
作者: zerof (猫橘毛发呆雕像)   2016-07-19 02:06:00
认知就是 by ref, 你要不要贴个参考资料说它不是?
作者: s860134 (s860134)   2016-07-19 02:21:00
stackoverflow 986006 也是讨论得乱七八糟XDhttps://goo.gl/aXGATb
作者: brightwish (密码同帐号)   2017-07-19 07:24:00
python宣告变量其实是把物件参照(变量名称)指向物件名称(值) 所以是呼叫物件参照
作者: LessonWang (橘白Cat)   2017-07-19 08:26:00
真的众说纷纭 ...
作者: Yshuan (倚絃)   2017-07-19 16:36:00
开发角度上 默认变量都是ref来去预防side effect为佳任何assinment都要有心理预期 上保险不会亏
作者: akasan (KITO)   2017-11-02 00:43:00
valgrind, 但 windowns 版的没试过XDlinux 上那真的是不二选择了
作者: Linux (Windows)   2017-11-02 00:45:00
我是用 Windows ....>"<

Links booklink

Contact Us: admin [ a t ] ucptt.com