On Thursday, 1 March 2018 at 07:34:38 UTC, Cym13 wrote:
On Wednesday, 28 February 2018 at 22:55:19 UTC, Seb wrote:
On Wednesday, 28 February 2018 at 21:47:40 UTC, Cym13 wrote:
[...]
I know that I am repeating myself, but manually closing the
file isn't needed in D. It's refCounted and will
On Wednesday, 28 February 2018 at 22:55:19 UTC, Seb wrote:
On Wednesday, 28 February 2018 at 21:47:40 UTC, Cym13 wrote:
On Tuesday, 27 February 2018 at 16:17:20 UTC, Jonathan wrote:
I know Python's `with` statement can be used to have an
automatic close action:
```
with open("x.txt") as
On Wednesday, 28 February 2018 at 21:47:40 UTC, Cym13 wrote:
On Tuesday, 27 February 2018 at 16:17:20 UTC, Jonathan wrote:
I know Python's `with` statement can be used to have an
automatic close action:
```
with open("x.txt") as file:
#do something with file
#`file.close()`
On Wednesday, 28 February 2018 at 22:00:11 UTC, meppl wrote:
On Wednesday, 28 February 2018 at 21:47:40 UTC, Cym13 wrote:
On Tuesday, 27 February 2018 at 16:17:20 UTC, Jonathan wrote:
[...]
Others have discussed that particular case at length, but to
provide a more generic answer the
On Wednesday, 28 February 2018 at 21:47:40 UTC, Cym13 wrote:
On Tuesday, 27 February 2018 at 16:17:20 UTC, Jonathan wrote:
[...]
Others have discussed that particular case at length, but to
provide a more generic answer the correct way to translate a
python context manager is to use
On Tuesday, 27 February 2018 at 16:17:20 UTC, Jonathan wrote:
I know Python's `with` statement can be used to have an
automatic close action:
```
with open("x.txt") as file:
#do something with file
#`file.close()` called automatically
```
I know D's `with` statement does
On Tuesday, 27 February 2018 at 16:18:43 UTC, Stefan Koch wrote:
On Tuesday, 27 February 2018 at 16:17:20 UTC, Jonathan wrote:
I know Python's `with` statement can be used to have an
automatic close action:
```
with open("x.txt") as file:
#do something with file
#`file.close()`
yes, for classes you can use scoped:
import std.stdio;
import std.typecons : scoped;
class A
{
void saySomething()
{
writeln("Hi from A");
}
~this()
{
writeln("Destruct A");
}
}
void main()
{
with(scoped!A())
{
saySomething();
On Tuesday, 27 February 2018 at 16:18:43 UTC, Stefan Koch wrote:
On Tuesday, 27 February 2018 at 16:17:20 UTC, Jonathan wrote:
I know Python's `with` statement can be used to have an
automatic close action:
```
with open("x.txt") as file:
#do something with file
#`file.close()`
I know Python's `with` statement can be used to have an automatic
close action:
```
with open("x.txt") as file:
#do something with file
#`file.close()` called automatically
```
I know D's `with` statement does something different but is there
some sort of equivalent?
On Tuesday, 27 February 2018 at 16:17:20 UTC, Jonathan wrote:
I know Python's `with` statement can be used to have an
automatic close action:
```
with open("x.txt") as file:
#do something with file
#`file.close()` called automatically
```
I know D's `with` statement does
11 matches
Mail list logo