New answers tagged

1 vote
Accepted

Finding files using multiple coroutines

OK, there's a number of things I'd change about your code. I'll go through what you posted, making suggestions based on what you have already, then I'll make some additional suggestions. ...
user avatar
4 votes
Accepted

File Abstraction Library

Okay, here are some quick random thoughts: in the places where there is stuff.Where(something).Single() (or .First(), etc.), ...
user avatar
1 vote

Finding files using multiple coroutines

Is there anything wrong with this code or what needs to be improved? Yes. Read the documentation. package io/ioutil func ReadDir(dirname string) ([]fs.FileInfo, error) As of Go 1.16, os.ReadDir is a ...
user avatar
  • 3,316
4 votes
Accepted

Faster way to find duplicates in a directory using Python

Delete commented-out code blocks like # import sys # args = sys.argv # if len(args) < 2: # print('Directory is not specified') This is the kind of ...
user avatar
3 votes

Python script for removing files in folders

Your code can be simplified through the usage of os.walk() and pathlib.Path. ...
user avatar
2 votes

Python script for removing files in folders

For loops inside for loops are necessary for this use case, you can however decrease indention levels by extracting code blocks into methods: ...
user avatar
  • 748
2 votes

File read/write methods

Perhaps it would be useful to look at the linux function with the same name. flock() places advisory locks only; given suitable permissions on a file, a process is free to ignore the use of flock() ...
user avatar
2 votes

Mount point API for Linux systems

Is there a better approach than parsing the output of mount using a regex? Probably? You care about machine legibility, not human legibility; so if you were sticking to a basic mountpoint search you ...
user avatar
1 vote

I have written a method to write any string in file. Should I close file or not

As it was stated by others this problem has been solved by many logging libraries So, you don't need to do it yourself But if you want to do that by your own then here are my observations Please ...
user avatar
  • 5,770

Top 50 recent answers are included