A few interesting Python things that I always forget how to do. The problem is I don't write Python code on a daily basis, nor have I done so for many years like I did Perl, so I tend to forget things in between the times I do write it. I'll add more here as I come across them.
Converting int to a string inside a print statement, note the %(var)s part.
print("\nServices running on localhost:%(port)s\n" % {'port': port})
Catching CTRL-C:
def signal_handler(signal, frame):
print('You pressed Ctrl+C!')
print("Exiting...")
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
Full absolute path for a log file
logfile = join(dirname(normpath(abspath(__file__))), 'file.log')
Subscribe to:
Post Comments (Atom)
Current Audible Reading List
Title You Never Forget Your First: A Biography of George Washington A Self-Made Man: The Politica...
-
As part of a project I'm working on right now I wanted to know what the "optimal" settings were for running OpenVAS on an ODRO...
-
By default the OPenVAS security assistant listens on port 80 and redirects connections to port 9392, this causes issues if you want to run a...
-
I often have need to use Tor for various testing purposes, mainly to determine how an adversary uses it, and I often just want to run it fro...
No comments:
Post a Comment