What is the equivalent of the C# “using” block in IronPython?

前端 未结 5 860
不思量自难忘°
不思量自难忘° 2020-12-06 05:09

What\'s the equivalent of this in IronPython? Is it just a try-finally block?

using (var something = new ClassThatImp         


        
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-06 05:42

    IronPython supports using IDisposable with with statement, so you can write something like this:

    with ClassThatImplementsIDisposable() as something:
        pass
    

提交回复
热议问题