# Tag Info

## New answers tagged file-system

2

Requirements The requirements are somewhat imprecise because they rely on untold assumptions about the filenames we should expect. Before implementing anything, we should try to think about the different inputs we can have and how we should handle them. In our case, this could correspond to: what if the regexp does not match (no underscore or less than 3 ...

5

Formatting The code formatting is good. The only major gripe I have is that there are some long lines (117 chars). Part of this is due to the high level of indenation, which we'll solve in another way, but even with heavily indented code, lines can be shorter. I use the black code formatter (with a linelength of 79) to format my code, so I don't have to ...

2

It sure sounds like you're running out of memory as you try to build (or allocate) the buffer. You need to figure out how big a buffer you can (or want to) use. You'll need to ask the system how much RAM it has, and how much is available, and make your buffer that large. You might get a small boost by opening the file as explicitly write-only. You'll need ...

2

I spent several weeks writing and tuning a script that moves old files to a timestamped Zip file. Here are a few guidelines I learned that may help: 1) Move variables into script parameters so they can be changed at runtime without editing the file: Param($File_Path = "C:\Users\Administrator\Downloads\Testing\*", #File path of file to be cleaned$...

3

import os, sys, zipfile, fnmatch, glob, sys, time, datetime, smtplib, logging is a prime example why you should not cram all your imports on a single line. Why? If you have a closer look, you will see that there is a double import of sys. It is also good practice to group imports by "topic", i.e. imports that have similar purposes. Something like import ...

2

Welcome to Code Review. Your code is understandable, so we can, more or less, figure out what it does, but it is always nice for reviewers to hear you say what you use a piece of code for, what its purpose is, what the code itself specifically does, and to have some usage examples. This also helps you to reflect on the choices you made. I couldn't get your ...

1

Look into using HashSets. If you want to see if an item is already in a list, you have to search through thousands of list items. With HashSets, it can perform the check instantly. Go through your list of directory names alphabetically. Every time you look at a directory name, pass it through a method that will remove " - Copy..." etc from the end using ...

2

Okay I spent just a little while with your code @Valentyn, and I think it is mostly unharmed... sql_utils/__init__.py import os def walked_sql_paths(config, sub_dir): """ Generates tuple of absolute and relative file paths - config should contain a 'MAIN_DIR' key with a value similar to - /home/Mentor - `/home/...

2

It's recomended to use enumerate rather than iter, _ and indexing. for iter, abs_path in enemerate(mentors_sql_abs): mentors_sql[iter][0] = abs_path It's better to use zip rather than build mentors_sql manually. Your function could futher be simplified if you don't extend mentors_sql_* and just yield the values. Please only use one string delimiter, ...

4

I spent sometime with the code you've currently posted @wizofe, I'm not sure if it'll ever be the same again... Side note; I heard it rumored that the character limits are just a bit more relaxed than on other sub-stacks... or in other-words this may get a bit verbose, or in other-other-words it could be another one of those posts so a snack and drink is ...

Top 50 recent answers are included