由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - newbie python question
相关主题
mutating input argument不应该鼓励吧Python中如何快速查询dict是否存在某key
没人觉得python的string是immutable不爽吗?python有快速loop over dict的方法吗?
return value of a python function...a python question
Python Q: function pass in struct pointer, come back with data filled怎么用python把这个data读进去,变成dict结构
python 区别于其他语言的根本?写Python 的苦恼之一:有人当c用,有人当bash用,有人当FP用。当然也有人当python用
请教一个python的概念问题王垠对google的看法 (转载)
如何用Python或者Perl抓取文本?python 水平如何提高
做web服务的语言怎么学习python的函数里面调用函数本身(函数递归)?
相关话题的讨论汇总
话题: python话题: newbie话题: change话题: reference话题: int
进入Programming版参与讨论
1 (共1页)
c********e
发帖数: 383
1
in C i can do,
int i;
int & j = i;
then when i change i's value I will see the change reflected in j as well.
how to do this in python. a quick search around didnt ring any bell.
thx.
c*****g
发帖数: 119
2
use list or other mutable objects.

【在 c********e 的大作中提到】
: in C i can do,
: int i;
: int & j = i;
: then when i change i's value I will see the change reflected in j as well.
: how to do this in python. a quick search around didnt ring any bell.
: thx.

j*****k
发帖数: 1198
3
怎么转战场了?Perl里面都有reference, python里面没有?

【在 c********e 的大作中提到】
: in C i can do,
: int i;
: int & j = i;
: then when i change i's value I will see the change reflected in j as well.
: how to do this in python. a quick search around didnt ring any bell.
: thx.

c********e
发帖数: 383
4
thx

【在 c*****g 的大作中提到】
: use list or other mutable objects.
c********e
发帖数: 383
5
picked python to make a quick log parser to do some offline time analysis
and learn something new...

【在 j*****k 的大作中提到】
: 怎么转战场了?Perl里面都有reference, python里面没有?
d*******8
发帖数: 3182
6
没有

【在 j*****k 的大作中提到】
: 怎么转战场了?Perl里面都有reference, python里面没有?
r****t
发帖数: 10904
7
python里面全是by reference吧。

【在 d*******8 的大作中提到】
: 没有
d*******8
发帖数: 3182
8
as i knew, only the elements in list and dict are by reference.
for example:
i = [3, 5]
j = i ==> j is [3, 5]
i[1] = 1 ==> i is [3, 1] and j is [3, 1]

【在 r****t 的大作中提到】
: python里面全是by reference吧。
r****t
发帖数: 10904
9
所有的attribute也是mutable的。你说的这么几种正好就是所有的immutables
r****t
发帖数: 10904
10
a = [1]
b = a
after this, when you change b[0] to any value, a[0] is also changed
accordingly:
b[0] = 5
assert a[0]==5
b[0] = 'dfadf'
assert a[0]=='dfadf'
这是因为list的元素是mutable的。python全是by reference.

【在 c********e 的大作中提到】
: in C i can do,
: int i;
: int & j = i;
: then when i change i's value I will see the change reflected in j as well.
: how to do this in python. a quick search around didnt ring any bell.
: thx.

1 (共1页)
进入Programming版参与讨论
相关主题
怎么学习python的函数里面调用函数本身(函数递归)?python 区别于其他语言的根本?
python, 怎么能把 tree存到 memory了 ?请教一个python的概念问题
Python pandas 是坑不?如何用Python或者Perl抓取文本?
How to use reflection in C# to do this job?做web服务的语言
mutating input argument不应该鼓励吧Python中如何快速查询dict是否存在某key
没人觉得python的string是immutable不爽吗?python有快速loop over dict的方法吗?
return value of a python function...a python question
Python Q: function pass in struct pointer, come back with data filled怎么用python把这个data读进去,变成dict结构
相关话题的讨论汇总
话题: python话题: newbie话题: change话题: reference话题: int