Redian新闻
>
免费送最高$250 Amazon GC 任意消费一笔SPG 信用卡
avatar
免费送最高$250 Amazon GC 任意消费一笔SPG 信用卡# Chemistry - 化学
q*i
1
统计下多少人吃了午饭以后会困,多少人吃了晚饭以后会困。
我先来,我吃了午饭会困,有时甚至抗不住要睡觉。吃了晚饭不会困,一点也不会。
avatar
t*d
2
现在还是学生身份F1,还没有毕业,好像只有毕业了找到工作单位了才能办理豁免,但
是比较担心到时候申请OPT的时候会有影响,有人有类似经验吗?谢谢啦
avatar
g*y
3
用的H&R block不支持这个,第一次填join filing。不知道在那个位置填,怎么填两个
人的。另外我们其中一个人的去年收入不到$5000。
avatar
m*e
4
In following python code, what is the difference between dict.setitem and
setattr ?
when I comment the setattr statement, I cannot run g.abcd. But if I keep the
setattr statement,
I can run both g.abcd and g['abcd'], which return the same value 300
id(g.abcd) and id(g['abcd']) returns the same value.
I am confused: dict.setitem should insert a hash pair into the
hash table. setattr should add an extra attributes (or field, or member) to
class dict. so they seem to be different thing. Therefore I think it is
expected that eliminating setattr will fail g.abcd. But I don't understand
why id() returns the same value for g.abcd and g['abcd'], why they refer to
the same thing?
thx
=================
class goc(dict):
def __init__(self, name):
dict.__init__(self)
self._name = name
def __setitem__(self, key, value):
dict.__setitem__(self, key, value) # setattr(self, key, value) # g=goc()
g.__setitem__('abcd', 300)
=================
avatar
b*n
5
Starwood Preferred Guest信用卡 开卡25000 bonus points 最高可入住12晚酒店
http://goo.gl/vJ71M
Earn 10,000 Starpoints with your first purchase and an additional 15,000
Starpoints when you spend $5,000 in 6 months 可以直接兑换250刀amazon gift
card
http://goo.gl/vJ71M
填完后会在60秒告诉你结果,这个卡是第一年免年费的,之后是$65, 可以在第二年关
闭避免被收取年费。即使第二年开始有年费,个人觉得还是一张值得长期使用的信用卡
。 消费一笔后两周内会把10000 point在你卡上,不会使用的人可以兑换$100
giftcard. 选择其他的 giftcard(Starbucks, Gap,Nordstrom)请选择Redeem in other
partners。请注意这一万点就可以换到最高5晚的category 1的酒店入住了。
下面的是非常关键的内容:
请大家尽快不要把点数兑换以上的250刀 amazon gift card,因为可以直接使用获得的
点数入住SPG酒店,Category 1: 以aloft为例,可以直接用2000points/晚 入住周末
房,或者以1200 points+25刀 在任意天入住。 Category 2: 以Four Points by
Sheraton为例,可以使用3000points/晚 入住周末房, 或者以1600 points +30刀在任
意天入住。
即使是消费第一笔后获得的10000points,也可以获得最高五晚的酒店入住。而且这类
酒店在中国区也是有效的。如果消费满5000刀,更可以获得另外的最高七晚的酒店入住。
avatar
f*2
6
不学习的话,吃完哪顿饭都没事。
要学习的话,早饭之后会饿,午饭,晚饭之后都会困。
avatar
t*d
7
自己顶下。。。
avatar
P*1
8
联邦税不管在哪个州。看你们有没有收到1042S。treaty只能用于学生(含OPT期间)up
to 5000/人。
如果没有收到1042S,每人填一份8833说明自己的情况,两人的免税总额以负数形式填
入1040 Line 21
avatar
M*P
9
setattr modifies g.__dict__ not the items in the dictionary.
try g.__dict__ with or without setattr() and you will see the difference.

the
to

【在 m*****e 的大作中提到】
: In following python code, what is the difference between dict.setitem and
: setattr ?
: when I comment the setattr statement, I cannot run g.abcd. But if I keep the
: setattr statement,
: I can run both g.abcd and g['abcd'], which return the same value 300
: id(g.abcd) and id(g['abcd']) returns the same value.
: I am confused: dict.setitem should insert a hash pair into the
: hash table. setattr should add an extra attributes (or field, or member) to
: class dict. so they seem to be different thing. Therefore I think it is
: expected that eliminating setattr will fail g.abcd. But I don't understand

avatar
k*a
10
我每天最精神的一段时间就是吃午饭的时候
吃饭前饿得犯困,吃午饭之后打着瞌睡盼下班
就吃午饭的半个小时神采奕奕

【在 q****i 的大作中提到】
: 统计下多少人吃了午饭以后会困,多少人吃了晚饭以后会困。
: 我先来,我吃了午饭会困,有时甚至抗不住要睡觉。吃了晚饭不会困,一点也不会。

avatar
m*e
11
thx,
but why id() return the same value for both g[abcd] and g.abcd, which
suggests they actually are the same thing (or place) in the memory

【在 M*P 的大作中提到】
: setattr modifies g.__dict__ not the items in the dictionary.
: try g.__dict__ with or without setattr() and you will see the difference.
:
: the
: to

avatar
c*k
12
都不困。

【在 q****i 的大作中提到】
: 统计下多少人吃了午饭以后会困,多少人吃了晚饭以后会困。
: 我先来,我吃了午饭会困,有时甚至抗不住要睡觉。吃了晚饭不会困,一点也不会。

avatar
M*P
13
could be that g['abcd'] is getting it's value from g.abcd or vice versa.
as long as the program does what you want to do, why bother to know how it's
done under the hood?

【在 m*****e 的大作中提到】
: thx,
: but why id() return the same value for both g[abcd] and g.abcd, which
: suggests they actually are the same thing (or place) in the memory

avatar
n*e
14
是的.

【在 q****i 的大作中提到】
: 统计下多少人吃了午饭以后会困,多少人吃了晚饭以后会困。
: 我先来,我吃了午饭会困,有时甚至抗不住要睡觉。吃了晚饭不会困,一点也不会。

avatar
r*t
15
int is immutable:
>> a, b = 12, 12
>> assert(id(a)==id(b))
这是 python 基础,最好看看文档。 python容许不怎么懂的程序员也能勉强用,
learning curve 低。不过一旦用多了就出问题,所以大家都是边用边学。

the
to

【在 m*****e 的大作中提到】
: In following python code, what is the difference between dict.setitem and
: setattr ?
: when I comment the setattr statement, I cannot run g.abcd. But if I keep the
: setattr statement,
: I can run both g.abcd and g['abcd'], which return the same value 300
: id(g.abcd) and id(g['abcd']) returns the same value.
: I am confused: dict.setitem should insert a hash pair into the
: hash table. setattr should add an extra attributes (or field, or member) to
: class dict. so they seem to be different thing. Therefore I think it is
: expected that eliminating setattr will fail g.abcd. But I don't understand

avatar
l*s
16
很正常的习惯
呵呵

【在 q****i 的大作中提到】
: 统计下多少人吃了午饭以后会困,多少人吃了晚饭以后会困。
: 我先来,我吃了午饭会困,有时甚至抗不住要睡觉。吃了晚饭不会困,一点也不会。

avatar
f*n
17
In Python, every value is a pointer to an object. Assigning one variable to
another copies the pointer so you have two pointers that point to the same
object. Since they point to the same object, the id() will be the same.
a = object()
b = a
# id(a) and id(b) are the same
c = object()
b = c
# id(b) and id(c) are the same,
# different from id(a) which is the same as before
Just like in C++ for example:
object *a = new object; // pretend we have a class called "object"
object *b = a;
// a and b are the same address
object *c = new object;
b = c;
// b and c are the same address,
// different from a which is the same as before

【在 m*****e 的大作中提到】
: thx,
: but why id() return the same value for both g[abcd] and g.abcd, which
: suggests they actually are the same thing (or place) in the memory

avatar
d*n
18
都困

【在 q****i 的大作中提到】
: 统计下多少人吃了午饭以后会困,多少人吃了晚饭以后会困。
: 我先来,我吃了午饭会困,有时甚至抗不住要睡觉。吃了晚饭不会困,一点也不会。

avatar
f*n
19
What does immutable have to do with it?
>>> a = 500
>>> b = 500
>>> id(a) == id(b)
False

【在 r****t 的大作中提到】
: int is immutable:
: >> a, b = 12, 12
: >> assert(id(a)==id(b))
: 这是 python 基础,最好看看文档。 python容许不怎么懂的程序员也能勉强用,
: learning curve 低。不过一旦用多了就出问题,所以大家都是边用边学。
:
: the
: to

avatar
j*1
20
both~ if I eat heavy stuff
avatar
V*r
21
CPython这个参考实现里,100以内的整数被缓存,所以id一样。
这个是implementation-specific的,不是Python语言的一部分,不可依赖。

【在 f*******n 的大作中提到】
: What does immutable have to do with it?
: >>> a = 500
: >>> b = 500
: >>> id(a) == id(b)
: False

avatar
a*o
22
如果去中餐馆吃午饭,十有八九会犯困,屡试不爽,去其他店
吃午餐,从来不犯困,偶认为是味精搞的鬼。

【在 q****i 的大作中提到】
: 统计下多少人吃了午饭以后会困,多少人吃了晚饭以后会困。
: 我先来,我吃了午饭会困,有时甚至抗不住要睡觉。吃了晚饭不会困,一点也不会。

avatar
r*t
23
nice. learned something new. 这个问题有文档吗?还是从实现的源码看来的?

【在 V*********r 的大作中提到】
: CPython这个参考实现里,100以内的整数被缓存,所以id一样。
: 这个是implementation-specific的,不是Python语言的一部分,不可依赖。

avatar
q*i
24
我觉得是太多油了。我去韩国博厚家吃午饭当时都撑死乐,结果下午4点就饿了

【在 a***o 的大作中提到】
: 如果去中餐馆吃午饭,十有八九会犯困,屡试不爽,去其他店
: 吃午餐,从来不犯困,偶认为是味精搞的鬼。

avatar
V*r
25

貌似是偶然跟别人讨论到的。前文“100以内”说得不准确,也没必要记,
设计思想就是常用的小整数缓存起来,避免频繁在堆上malloc造成不必要的开销。
刚翻了翻Python 3.4源码(注:Python 3里long已经和int统一了):
http://hg.python.org/cpython/file/3.4/Objects/longobject.c
#ifndef NSMALLPOSINTS
#define NSMALLPOSINTS 257
#endif
#ifndef NSMALLNEGINTS
#define NSMALLNEGINTS 5
#endif
/* Small integers are preallocated in this array so that they
can be shared.
The integers that are preallocated are those in the range
-NSMALLNEGINTS (inclusive) to NSMALLPOSINTS (not inclusive).
*/
前面说了,这个特性不是 *Python语言* 标准的一部分,
只是一个特定实现的特定优化手段,不要依赖这个特性做事。

【在 r****t 的大作中提到】
: nice. learned something new. 这个问题有文档吗?还是从实现的源码看来的?
avatar
g*n
26
都有困的可能。在国内的时候,经常吃完晚饭就在沙发上睡着了。
avatar
a*z
27
hand hand

【在 f********2 的大作中提到】
: 不学习的话,吃完哪顿饭都没事。
: 要学习的话,早饭之后会饿,午饭,晚饭之后都会困。

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