This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import __future__, sys | |
[name for name in __future__.all_feature_names if getattr(__future__, name).optional <= sys.version_info < getattr(__future__, name).mandatory] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# resource is Linux/OsX only | |
import sys | |
import resource | |
# Gives result on Integer, MegaBytes on Linux/OsX, or 0 on Windows since info is not available. | |
int(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss * resource.getpagesize() / 1024 / 1024 | |
if not sys.platform.startswith("win") else 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def seconds_time_to_human_string(self, time_on_seconds=0): | |
"""Calculate time, with precision from seconds to days.""" | |
minutes, seconds = divmod(int(time_on_seconds), 60) | |
hours, minutes = divmod(minutes, 60) | |
days, hours = divmod(hours, 24) | |
human_time_string = "" | |
if days: | |
human_time_string += "%02d Days " % days | |
if hours: | |
human_time_string += "%02d Hours " % hours |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
progressbar = lambda i: sys.stdout.write("[{}] {}%\r".format( | |
'#' * (70 * i // 100) + '.' * (70 - 70 * i // 100), 100 * i // 100)[:80]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import sys | |
import logging as log | |
from copy import copy | |
if not sys.platform.startswith("win") and sys.stderr.isatty(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
def int_to_roman(integer_argument): | |
"""Convert an integer to Roman numerals. | |
>>> int_to_roman(0) | |
Traceback (most recent call last): | |
ValueError: Argument must be between 1 and 3999 | |
>>> int_to_roman(-1) | |
Traceback (most recent call last): |
NewerOlder