Redian新闻
>
New England (NH, and ME), Ohio环境招人
avatar
f*y
2
比如文件和socket?
avatar
x*a
3
Hi, I am done with this recruiting. I am not sure if they are still interested on hiring, if you are interested in the position, please contact the firm directly.
avatar
w*g
4
java里面要explicitly close。C++里那讨RAII貌似在java里不行(不确信,希望java
高手指正).
python不知道。

【在 f*******y 的大作中提到】
: 比如文件和socket?
avatar
s*s
5
很赞~~~~虽然偶不适合,但还是赞一记

【在 x*******a 的大作中提到】
: Hi, I am done with this recruiting. I am not sure if they are still interested on hiring, if you are interested in the position, please contact the firm directly.
avatar
g*g
6
In java, you are still recommended to manually close an IOStream.
In certain case, you want to do it in a finally block,
that prevents some problem you may see in C++ coz the block is
guarranteed to be executed. It's also notable that since GC will reclaim an
non-referenced instance automatically, this is often not an issue even if
you didn't do that.

【在 f*******y 的大作中提到】
: 比如文件和socket?
avatar
a*a
7
zan~~~~
avatar
f*y
8
用finally是一个好的做法呢?
貌似google一下有人不太建议

an

【在 g*****g 的大作中提到】
: In java, you are still recommended to manually close an IOStream.
: In certain case, you want to do it in a finally block,
: that prevents some problem you may see in C++ coz the block is
: guarranteed to be executed. It's also notable that since GC will reclaim an
: non-referenced instance automatically, this is often not an issue even if
: you didn't do that.

avatar
a*e
9
Zan!!!
avatar
t*t
11
thanks for sharing!
avatar
r*t
12
In Python, everything (file descriptor, sockets, etc etc...) is automatically closed/GCed when the last name referring to it goes out of its scope.
但是要记得 shutdown socket。
socket is a different story. Supposedly you should shutdown() and then close() your connection. So, imagine you forgot about one socket you created, when it is GCed, socket.close() is automatically called. That'll close your side of the connection (you are fine) but leave the other side of connection wait forever: because he/s

【在 f*******y 的大作中提到】
: 比如文件和socket?
avatar
j*y
13
I am wondering why this girl know so much infor.?
amazing.
avatar
d*q
14
python adopt handle counting technique for resource management.
when the count of object becomes zero, it will be released automatically.
so even you don't close a opened file object manually, it will be close when
reaching the end of block
for Jython it is another story.
avatar
h*o
15
in java, you should always release scarce non-memory resources in your code
explicitly without relying on GC.
avatar
a*a
16
In python 2.5,
from __future__ import with_statement
You can write a special objective working with the `with' statement, such as
with SomeClass() as obj:
## do you things here
## when leaving the current context normally or by exception,
## the obj's speciall method will be invoked and do the house
## cleaning job.
avatar
a*a
17
For example,
with file('foo.bar') as foobar:
for line in foorbar:
print line

as

【在 a**a 的大作中提到】
: In python 2.5,
: from __future__ import with_statement
: You can write a special objective working with the `with' statement, such as
: with SomeClass() as obj:
: ## do you things here
: ## when leaving the current context normally or by exception,
: ## the obj's speciall method will be invoked and do the house
: ## cleaning job.

avatar
r*t
18
这个 with statement 今天俺也贴了一个

【在 a**a 的大作中提到】
: For example,
: with file('foo.bar') as foobar:
: for line in foorbar:
: print line
:
: as

avatar
h*i
19
对,其实很像c++的shared_ptr

when

【在 d***q 的大作中提到】
: python adopt handle counting technique for resource management.
: when the count of object becomes zero, it will be released automatically.
: so even you don't close a opened file object manually, it will be close when
: reaching the end of block
: for Jython it is another story.

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