avatar
newbie python question# Programming - 葵花宝典
c*e
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.
avatar
c*g
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.

avatar
j*k
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.

avatar
c*e
4
thx

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

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

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

【在 d*******8 的大作中提到】
: 没有
avatar
d*8
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吧。
avatar
r*t
9
所有的attribute也是mutable的。你说的这么几种正好就是所有的immutables
avatar
r*t
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.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。