f*y
2 楼
比如文件和socket?
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.
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?
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?
a*a
7 楼
zan~~~~
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.
貌似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.
a*e
9 楼
Zan!!!
g*g
10 楼
sure finally is useful, check
http://www.ibm.com/developerworks/java/library/j-praxis/pr21.html
【在 f*******y 的大作中提到】
: 用finally是一个好的做法呢?
: 貌似google一下有人不太建议
:
: an
http://www.ibm.com/developerworks/java/library/j-praxis/pr21.html
【在 f*******y 的大作中提到】
: 用finally是一个好的做法呢?
: 貌似google一下有人不太建议
:
: an
t*t
11 楼
thanks for sharing!
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?
但是要记得 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?
j*y
13 楼
I am wondering why this girl know so much infor.?
amazing.
amazing.
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.
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.
h*o
15 楼
in java, you should always release scarce non-memory resources in your code
explicitly without relying on GC.
explicitly without relying on GC.
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.
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.
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.
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.
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.
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.
相关阅读
大家想转行么?转做销售/市场,在美国行得通么?哪位给介绍一下FE、PE考试?求推荐工作,唉Billable Rate,工资及找工作 (1)水资源工程方向,小硕,如果有两三篇文章,找工作管用吗?求定位,前途一片迷茫阿Discover 信用卡送$75+$60 限时 Chase信用卡送350刀哪里可以免费下到美国降雨的实时数据?[合集] 准备回去了, 最新进展:毕业好几个月了,打电话回国问了一下以A position at University of Arizona出个FE Review Manual, 50刀免邮费找工作请教看到本版对工资的讨论,忍不住说两句"2 Year Faculty Position"有什么关于EHS的certificate值得考吗问个问题。有urban planning的么?谢谢Tetra Tech just got a big contractPhD versus Job?我要实习!Senior Project Manager