Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

using (var something = new ClassThatImplementsIDisposable())
{
  // stuff happens here
}
like image 230
Josh Kodroff Avatar asked Nov 18 '09 16:11

Josh Kodroff


People also ask

What is the equivalent of class in C?

There is nothing equivalent to classes . Its a totally different paradigm. You can use structures in C. Have to code accordingly to make structures do the job.

Is there a replacement for C?

There's actually quite a few things that can be used for low level programming. Here's some used in the past with advantages over C. Smalltalk and Haskell were used for prototype OS's or OS replacement layers. Cyclone, Popcorn, C0, and Typed Assembly Language do better than C while keeping much of it.

Is C+ the same as C?

The main difference between C and C++ is that C++ is a younger, more abstract language. C and C++ are both general-purpose languages with a solid community. C is a lightweight procedural language without a lot of abstraction. C++ is an object-oriented language that provides more abstraction and higher-level features.

Why is C not A or B?

Because C comes after B The reason why the language was named “C” by its creator was that it came after B language. Back then, Bell Labs already had a programming language called “B” at their disposal.


1 Answers

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

with ClassThatImplementsIDisposable() as something:
    pass
like image 191
Bojan Resnik Avatar answered Sep 28 '22 09:09

Bojan Resnik