This question already has an answer here:
How can I set file creation times in ZFS?
(1 answer)
Closed 12 months ago.
utime only modifies accessed and modified times. Is there a way to do modify the creation/birth time with Python?
Filesystem is ZFS if that matters.
You want touch functionality, and it's available in the os module using utime().
See https://docs.python.org/3.8/library/os.html#os.utime, and also
Implement touch using Python?
Related
This question already has answers here:
Passing IPython variables as arguments to bash commands
(4 answers)
Running Bash commands in Python
(11 answers)
Closed 2 years ago.
So I found this tool: https://github.com/elceef/dnstwist and I want to pass a list of domains into that tool then take the output and visualize it.
It operates through the command line, but how do I automate entering each domain and process the output automatically as well?
By the way I am using colab, so I would need a solution using jupyter notebooks!
Thanks!
If you want to do this programmatically I would not use the provided cli – although this would also be possible.
Instead you can create a small python script to do this.
Import dwintwist in your script and have a look at the main function in dwintwist.py to see how you call this.
Doesn't look to hard, but I don't know your programming skill level of course.
This question already has answers here:
how can I disable multiple instances of a python script?
(7 answers)
Closed 2 years ago.
When I open my program I want it to detect if the program is running already (if I launch it again while it's running). If it is I want to access the already running program and call a function there. But the problem is that I don't know how to access the already running program.
Thanks in advance!
I am confused by what you mean by "the script is the same script", but you can use import to get a function from a different file
otherprogram.py
def func(a):
return a
main.py
from otherprogram import func
print(func(5))
This question already has answers here:
python: complexity of os.path.exists with a ext4 filesystem?
(2 answers)
Closed 4 years ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
I have a ton of folders nested inside one another.
What is time complexity of Python's os.path.exists() ?
Does it change if used with different OS ?
os.path.exists just performs a system call and returns True if the path points to an existing file or directory.
Python seems to performa an lstat() system call on the given path.
If the operation only consists in a lookup in a hash table, then the cost is O(1), but it may depend on the Operating System and in how is it implemented internally.
Given you are asking the OS if a single file exists, it does not need to do any algorithmic logic, or go down your path... I don't see how it could be anything else than O(1).
This question already has answers here:
How can I profile Python code line-by-line?
(5 answers)
Closed 7 years ago.
I have a Python function in which I want to find most slowing-down places. Just not I'm using cProfile, but I have an additional functionality.
I don't want to split my function into a dozen of sub-functions: it looks a bit bulky and annoying.
Isn't there instead a way to profile a function line-by-line? Or add something like timer_start(timer_id) and timer_stop(timer_id) before and after each block of code I want to profile execution time?
If you are not using IPython already, you should give it a look. It has magic functions like %lprun which make line-by-line profiling easy. Take a look at Timing and Profiling in IPython
This question already has answers here:
Rewrite multiple lines in the console
(7 answers)
Closed 9 years ago.
I am currently working on a text-adventure, which should have a more or less complex fight system. To create such, I decided to generate a 16x16 tile battlefield, which will be represented by ASCII-characters. But, because a fight may take more than turn, I don't want to reprint the battlefield multiple times, but delete the "old" one and print the new situation to the same place. But I suppose that it won't work with sys.stdout.write() and sys.stdout.flush() since there have to be removed multiple lines. So my question is: how do I accomplish my goal? At the moment I open a new console window, where everything is reprinted, which is ahem... not very elegant.
Another problem would be the cross-platform use of the programm.
Check out the curses module (http://docs.python.org/2/library/curses.html).